:root {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #5e6ad2;
    --accent-hover: #7380ea;
    --border: #333333;
    
    /* Message types */
    --msg-system: #888888;
    --msg-action: #c678dd;
    --msg-timestamp: #666666;
    
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --sidebar-width: 280px;
    --user-sidebar-width: 320px;
    --tutorial-anomaly: #d9ae64;
}

:root[data-theme="light"] {
    --tutorial-anomaly: #846018;
    --bg-primary: #f6f7f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f4;
    --text-primary: #1f2328;
    --text-secondary: #59636e;
    --accent: #315ecf;
    --accent-hover: #214ca8;
    --border: #d7dce2;
    --msg-system: #6a737d;
    --msg-action: #8a4ab0;
    --msg-timestamp: #7a8490;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
}

#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-header {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.45rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-secondary);
    position: relative;
    z-index: 60;
}

.app-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.app-brand-mark {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    border: 1px solid var(--accent);
    border-radius: 5px;
    color: var(--accent-hover);
    background-color: rgba(94, 106, 210, 0.12);
    font: 600 0.72rem/1 var(--font-mono);
}

.app-brand-title {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.app-nav-button {
    min-height: 2.25rem;
    gap: 0.4rem;
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

.app-nav-button:hover,
.app-nav-button:focus-visible {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.app-nav-button:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.app-header-actions {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-left: auto;
}

.app-footer {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 1rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    position: relative;
    z-index: 55;
}

.app-footer-brand {
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.app-footer-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.app-footer-links button,
.app-footer-links .support-link {
    min-height: 1.6rem;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.73rem;
}

.app-footer-links button:not(:disabled):hover,
.app-footer-links button:not(:disabled):focus-visible,
.app-footer-links .support-link:hover,
.app-footer-links .support-link:focus-visible {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.app-footer-links .support-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.app-footer-links .support-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Tutorial-only investigation surfaces share the viewer's theme and layout. */
.tutorial-active .side-tabs { grid-template-columns: repeat(3, minmax(max-content, 1fr)); }
.tutorial-home-active .side-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tutorial-home-active [data-panel="users"] { display: none; }
.tutorial-home-active .viewer-header,
.tutorial-home-active #messages-container,
.tutorial-home-active #playback-controls { display: none !important; }
#tutorial-home { flex: 1; min-height: 0; overflow-y: auto; padding: 2.5rem; }
#tutorial-chapter { flex: 1; min-height: 0; overflow-y: auto; padding: 2.5rem; }
#tutorial-chapter-title { font-size: 1.75rem; line-height: 1.3; overflow-wrap: anywhere; }
.tutorial-chapter-intro { margin: 2rem 0; line-height: 1.7; }
#tutorial-chapter-score { margin: 1rem 0; color: var(--accent-hover); font-size: 0.95rem; line-height: 1.6; font-variant-numeric: tabular-nums; }
.tutorial-chapter-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.tutorial-chapter-actions > button { flex: 1 1 200px; min-width: 0; max-width: 100%; min-height: 44px; height: auto; white-space: normal; overflow-wrap: anywhere; }
.tutorial-chapter-actions > button:disabled { opacity: 0.45; cursor: default; }
.tutorial-chapter-summary { padding-top: 1.5rem; line-height: 1.7; overflow-wrap: anywhere; }
.tutorial-chapter-summary > p { margin-bottom: 0.75rem; }
.tutorial-chapter-next, .tutorial-chapter-personal { border-top: 1px solid var(--border); margin-top: 1.75rem; padding-top: 1.25rem; }
.tutorial-chapter-next h2 { font-size: 0.9rem; font-weight: 600; color: var(--accent-hover); margin-bottom: 0.5rem; }
.tutorial-chapter-next p { color: var(--text-secondary); font-size: 0.9rem; }
#tutorial-chapter-questions { margin-bottom: 1.5rem; }
#tutorial-chapter-questions fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
#tutorial-chapter-questions legend { font-size: 1.1rem; line-height: 1.5; margin-bottom: 1rem; }
#tutorial-chapter-questions label { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.8rem 0; min-height: 44px; line-height: 1.5; cursor: pointer; }
#tutorial-chapter-questions input { flex: none; margin-top: 0.3rem; accent-color: var(--accent); }
#tutorial-chapter-questions label:has(input:checked) { color: var(--accent-hover); }
#tutorial-chapter-questions span { min-width: 0; overflow-wrap: anywhere; }
.tutorial-question-feedback { border-left: 3px solid var(--accent); padding: 0.75rem 1rem; margin: 1rem 0; line-height: 1.7; }
.tutorial-hypothesis { border-top: 1px solid var(--border); padding-top: 1.5rem; }
.tutorial-hypothesis h2, #tutorial-chapter-questions .tutorial-hypothesis label { font-size: 1.15rem; line-height: 1.5; font-weight: 600; }
.tutorial-hypothesis-note { font-size: 0.85rem; color: var(--text-secondary); margin: 0.5rem 0 1rem; line-height: 1.6; }
#tutorial-hypothesis-input { display: block; box-sizing: border-box; width: 100%; min-height: 44px; padding: 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-secondary); color: var(--text-primary); font: inherit; line-height: 1.6; }
#tutorial-hypothesis-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tutorial-dossier .tutorial-hypothesis-text { border-top: 0; padding: 0; margin: 1rem 0; white-space: pre-wrap; overflow-wrap: anywhere; font-style: normal; font-size: 0.9rem; }
.tutorial-hypothesis .tutorial-question-feedback p + p { margin-top: 0.75rem; }
.tutorial-nobody-reveal { animation: tutorial-nobody-reveal 1s step-end; }
@keyframes tutorial-nobody-reveal { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tutorial-nobody-reveal { animation: none; } }
.tutorial-chapter-entry {
    display: block;
    width: 100%;
    flex: none;
    margin-top: 0.75rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    cursor: pointer;
}
.tutorial-chapter-entry:hover { background: var(--accent-hover); }
.tutorial-chapter-entry:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; }
#tutorial-chapter-back, .tutorial-chapter-entry { min-height: 44px; height: auto; white-space: normal; overflow-wrap: anywhere; padding: 0.75rem 1rem; max-width: 100%; }
@media (max-width: 760px) {
    #tutorial-chapter { padding: 1.25rem; }
    #tutorial-chapter .tutorial-dossier-heading { align-items: flex-start; }
    #tutorial-chapter .tutorial-dossier-heading img { width: 48px; height: 40px; flex-basis: 48px; }
}
.tutorial-dossier { max-width: 800px; margin: 0 auto; font-family: var(--font-mono); }
.tutorial-dossier-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.tutorial-dossier-heading img { flex: 0 0 96px; }
.tutorial-eyebrow { color: var(--accent-hover); text-transform: uppercase; font-size: 1rem; margin: 0 0 0.5rem; }
#tutorial-home-title { font-size: 3.5rem; line-height: 1.1; font-weight: 500; color: var(--text-primary); }
.tutorial-metadata { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.6rem 1rem; padding: 1.5rem 0; margin: 1.5rem 0; border-top: 1px solid var(--border); font-size: 0.85rem; }
.tutorial-metadata dt { color: var(--text-secondary); }
.tutorial-metadata dd { margin: 0; overflow-wrap: anywhere; }
.tutorial-progress-block { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; font-size: 0.85rem; }
[data-tutorial-percent] { font-variant-numeric: tabular-nums; color: var(--accent-hover); }
[data-tutorial-progress], .tutorial-file-reading progress { appearance: none; border: 0; height: 8px; width: 100%; min-width: 0; border-radius: 4px; overflow: hidden; background: var(--bg-tertiary); color: var(--accent); }
[data-tutorial-progress]::-webkit-progress-bar, .tutorial-file-reading progress::-webkit-progress-bar { background: var(--bg-tertiary); }
[data-tutorial-progress]::-webkit-progress-value, .tutorial-file-reading progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
[data-tutorial-progress]::-moz-progress-bar, .tutorial-file-reading progress::-moz-progress-bar { background: var(--accent); }
.tutorial-progress-block progress { grid-column: 1 / -1; height: 12px; }
.tutorial-premise { border-left: 3px solid var(--accent); padding: 0.25rem 0 0.25rem 1.25rem; margin: 2rem 0; line-height: 1.8; font-size: 0.9rem; }
.tutorial-premise p + p { margin-top: 0.75rem; }
.tutorial-premise strong { color: var(--accent-hover); }
#tutorial-start-btn { margin: 0 auto; width: fit-content; max-width: 100%; height: auto; min-height: 44px; padding: 0.8rem 1.5rem; font-family: inherit; border-radius: 6px; }
#tutorial-start-btn:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 4px; }
.tutorial-dossier blockquote, #findings-panel blockquote { border-top: 1px solid var(--border); margin: 1.75rem 0 0; padding-top: 1rem; font-style: italic; font-size: 0.8rem; line-height: 1.7; color: var(--text-secondary); }
.tutorial-reading-progress { display: grid; grid-template-columns: auto minmax(40px, 1fr) 3.5rem; align-items: center; gap: 0.75rem; margin: 0.75rem 0; font-size: 0.75rem; }
.tutorial-reading-progress strong { text-align: right; }
#findings-panel { padding: 0.75rem; overflow-y: auto; gap: 1rem; }
#findings-panel > * { flex-shrink: 0; min-width: 0; }
#findings-panel h3 { font-size: 0.82rem; line-height: 1.5; color: var(--accent-hover); }
#findings-panel h4 { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }
.tutorial-counters { display: grid; gap: 0.75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tutorial-counters > button { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; min-height: 44px; padding: 0.5rem 0.65rem; border: 1px solid transparent; border-radius: 4px; text-align: left; color: var(--text-primary); }
.tutorial-counters > button:hover { background: var(--bg-tertiary); }
.tutorial-counters > button[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-tertiary); }
.tutorial-counters > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#tutorial-category-empty { color: var(--text-secondary); font-size: 0.82rem; line-height: 1.6; }
.tutorial-character[hidden] { display: none; }
.tutorial-counters strong { color: var(--text-secondary); }
.tutorial-file-reading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; margin-bottom: 1rem; font-size: 0.75rem; }
.tutorial-file-reading span { overflow-wrap: anywhere; }
.tutorial-file-reading progress { grid-column: 1 / -1; height: 5px; }
#tutorial-completion { color: var(--text-primary); font-size: 0.85rem; }
.tutorial-character { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.82rem; overflow-wrap: anywhere; }
.tutorial-character summary { padding: 0.75rem; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--text-primary); }
.tutorial-character summary:hover { background: var(--bg-tertiary); }
.tutorial-character summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 5px; }
.tutorial-character-intro { margin: 0 0.75rem 0.75rem; color: var(--text-secondary); line-height: 1.6; }
.tutorial-character ul { padding: 0 0.75rem 0.75rem 1.75rem; margin: 0; line-height: 1.65; }
.tutorial-character ul:empty { display: none; }
.tutorial-character li + li { margin-top: 0.5rem; }
.tutorial-character-unknown { border-style: dashed; border-left: 3px solid var(--accent); }
.tutorial-character-relation { color: var(--text-secondary); }
.tutorial-character-hypothesis { font-weight: 600; color: var(--accent-hover); }
.tutorial-anecdote { border-left: 3px solid var(--text-secondary); }
.tutorial-anecdote .tutorial-character-intro { color: var(--text-primary); }
.tutorial-anomaly { border-left: 3px solid var(--tutorial-anomaly); }
.tutorial-anomaly summary { color: var(--tutorial-anomaly); }
.tutorial-anomaly ul { list-style: none; padding: 0 0.75rem 0.75rem; }
.tutorial-anomaly li { border-top: 1px solid var(--border); padding-top: 0.65rem; }
.tutorial-anomaly time { display: block; font: 0.72rem/1.6 var(--font-mono); color: var(--text-secondary); }
.tutorial-anomaly time[hidden] { display: none; }
.tutorial-anomaly li strong { display: block; color: var(--tutorial-anomaly); font-size: 0.78rem; margin: 0.2rem 0 0.45rem; }
.tutorial-related-stories { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; margin: 0 0.75rem 0.75rem; }
.tutorial-related-stories button { color: var(--accent-hover); text-align: left; text-decoration: underline; text-underline-offset: 3px; font: inherit; line-height: 1.5; padding: 0.35rem 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.tutorial-related-stories button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tutorial-announcement { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#tutorial-notice { position: fixed; z-index: 45; right: 0.75rem; bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px)); width: min(360px, calc(var(--user-sidebar-width) - 24px), calc(100vw - 24px)); max-height: calc(100dvh - 8rem); overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: start; gap: 0.35rem; padding: 0.7rem; background: var(--bg-secondary); border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2); }
#tutorial-notice[hidden] { display: none; }
#tutorial-notice-text { align-self: center; color: var(--text-primary); font-size: 0.82rem; line-height: 1.55; overflow-wrap: anywhere; }
#tutorial-notice-close { width: 44px; height: 44px; font-size: 1.25rem; }
#tutorial-notice-open { grid-column: 1 / -1; justify-self: start; text-align: left; min-height: 44px; color: var(--accent-hover); font: 600 0.8rem/1.5 var(--font-ui); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; max-width: 100%; }
#tutorial-notice button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 760px) {
    #tutorial-notice { position: static; width: 100%; max-height: 25vh; box-shadow: none; padding: 0.25rem 0.45rem; }
    .app-footer:has(#tutorial-notice:not([hidden])) { flex-shrink: 0; }
    .app-footer:has(#tutorial-notice:not([hidden])) > .app-footer-links { display: none; }
    .tutorial-related-stories button { min-height: 44px; }
}
.tutorial-home-mobile { display: none; }
@media (max-width: 760px) {
    #tutorial-home { padding: 1.25rem; }
    .tutorial-home-mobile { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
    .tutorial-home-mobile button { padding: 0.5rem; min-height: 44px; background: var(--bg-tertiary); border-radius: 4px; font-size: 0.8rem; }
    .tutorial-metadata { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
    .tutorial-metadata dd { margin-bottom: 0.75rem; }
    .tutorial-dossier-heading img { width: 64px; height: 54px; flex-basis: 64px; }
    .tutorial-reading-progress { grid-template-columns: minmax(0, 1fr) 3.5rem; }
    .tutorial-reading-progress label { grid-column: 1 / -1; }
}

.hidden {
    display: none !important;
}

/* --- Drop Zone --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#drop-zone {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    transition: background-color 0.3s ease;
    background: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.landing-controls {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2;
}

.drop-content {
    text-align: center;
    margin-block: auto;
    padding: 2rem 1.5rem;
    max-width: 640px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: fadeIn 0.6s ease-out forwards;
}

.landing-open-area {
    padding: 1.75rem 1.25rem;
    border: 1px dashed color-mix(in srgb, var(--text-secondary) 55%, var(--bg-secondary));
    border-radius: 8px;
    background-color: var(--bg-secondary);
    box-shadow: 0 12px 32px rgb(0 0 0 / 10%);
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.drop-folder {
    display: block;
    width: 64px;
    height: 54px;
    margin: 0 auto 0.75rem;
    transition: transform 160ms ease;
}

@media (hover: hover) {
    .landing-open-area:hover {
        border-color: var(--accent);
        background-color: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary));
    }

    .landing-open-area:hover .drop-folder {
        transform: translateY(-3px) rotate(-4deg);
    }
}

.landing-open-area:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

#drop-zone.drag-over .landing-open-area,
#drop-zone.drop-scanning .landing-open-area {
    border-color: var(--accent);
    border-style: solid;
    background-color: color-mix(in srgb, var(--accent) 16%, var(--bg-secondary));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

#drop-zone.drag-over .drop-folder {
    transform: translateY(-4px) rotate(-6deg);
}

@media (prefers-reduced-motion: reduce) {
    .landing-open-area,
    .drop-folder {
        transition: none;
    }

    #drop-zone .drop-folder {
        transform: none;
    }
}

.format-pills {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.format-pills .format-badge {
    width: 3.5rem;
    height: 3.5rem;
    padding: 0.25rem;
    border: 0;
    background: transparent;
    box-shadow: none;
    filter: drop-shadow(0 5px 4px rgb(0 0 0 / 18%));
}

.format-pills > :first-child {
    transform: rotate(-8deg);
}

.format-pills > :nth-child(2) {
    transform: translateY(-6px);
}

.format-pills > :last-child {
    transform: rotate(8deg);
}

.drop-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    letter-spacing: 0;
    color: #ffffff;
}

:root[data-theme="light"] .drop-content h1 {
    color: var(--text-primary);
}

.drop-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.02rem;
    line-height: 1.65;
}

.drop-content .landing-intro {
    max-width: 520px;
    margin: 0 auto 1.75rem;
    line-height: 1.6;
    text-wrap: pretty;
}

.landing-export-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    max-width: 460px;
    margin: 1.5rem auto 0;
    color: var(--text-secondary);
    text-align: left;
    font-size: 0.82rem;
    line-height: 1.45;
}

.landing-export-note svg {
    flex: 0 0 1.1rem;
    margin-top: 0.08rem;
    color: var(--accent-hover);
}

.landing-tutorial {
    margin-top: 1.75rem;
}

#tutorial-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    max-width: 100%;
    color: var(--accent-hover);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
}

#tutorial-btn svg { flex: 0 0 22px; }
#tutorial-btn span[data-i18n] { text-decoration: underline; text-underline-offset: 3px; }
#tutorial-btn:hover { color: var(--text-primary); }
#tutorial-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
#tutorial-btn:disabled { opacity: 0.6; cursor: wait; }
.drop-content .landing-tutorial p { margin: 0; font-size: 0.8rem; }

.landing-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.landing-privacy-note > svg {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    color: #63bda0;
}

.drop-instruction {
    min-height: 3.2rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.drop-instruction-label {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
}

.drop-file-types {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

#drop-zone.drag-over .drop-instruction-label,
#drop-zone.drop-scanning .drop-instruction-label {
    color: var(--accent-hover);
}

.drop-content p span {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background-color: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    color: var(--text-primary);
}

#browse-btn {
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

#browse-btn:hover {
    background-color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

#browse-btn:active {
    transform: translateY(0);
}

.buttons-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
}

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

@media (max-width: 520px) {
    #drop-zone {
        padding: 1rem;
    }

    .landing-controls {
        top: 0.75rem;
        right: 0.75rem;
    }

    .drop-content {
        width: min(100%, 23rem);
        padding: 2.5rem 1.5rem 1.75rem;
    }

    .drop-content h1 {
        font-size: 1.75rem;
    }

    .drop-content p {
        font-size: 0.96rem;
    }

    .buttons-container {
        flex-direction: column;
        gap: 0.65rem;
    }

    #browse-btn,
    .secondary-btn {
        width: 100%;
        min-height: 2.75rem;
        white-space: nowrap;
    }
}

/* --- Workspace & Sidebar --- */
#workspace {
    flex: 1;
    display: flex;
    min-height: 0;
    height: auto;
    overflow: hidden;
    position: relative;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.mobile-panel-close,
.mobile-workspace-button,
.mobile-panel-backdrop {
    display: none;
}

#sidebar {
    width: var(--sidebar-width);
    min-width: 220px;
    max-width: 55vw;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: width 0.12s ease;
}

#sidebar.hidden {
    display: none !important;
}

.sidebar-resizer {
    width: 8px;
    flex: 0 0 8px;
    cursor: col-resize;
    background: linear-gradient(to right, var(--border), transparent);
    position: relative;
    z-index: 11;
    touch-action: none;
}

.sidebar-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    width: 2px;
    height: 44px;
    border-radius: 999px;
    background-color: var(--bg-tertiary);
    transform: translateY(-50%);
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
body.resizing-sidebar .sidebar-resizer::after {
    background-color: var(--accent);
}

.sidebar-resizer:focus-visible,
.user-sidebar-resizer:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

body.resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

body.resizing-sidebar #sidebar {
    transition: none;
}

#sidebar.hidden + .sidebar-resizer {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.file-filter {
    display: grid;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.file-filter-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2.25rem;
    gap: 0.4rem;
    align-items: center;
}

#file-filter-input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: var(--font-ui);
    outline: none;
}

.advanced-file-filter-toggle {
    position: relative;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.advanced-file-filter-toggle:hover,
.advanced-file-filter-toggle.open,
.advanced-file-filter-toggle.has-filters {
    border-color: var(--accent);
    color: var(--text-primary);
}

.advanced-file-filter-toggle.has-filters {
    background-color: rgba(94, 106, 210, 0.18);
}

.filter-count {
    position: absolute;
    top: -0.35rem;
    right: -0.35rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.2rem;
    border: 2px solid var(--bg-secondary);
    border-radius: 999px;
    background-color: var(--accent);
    color: white;
    font: 700 0.62rem/0.85rem var(--font-ui);
    text-align: center;
}

.advanced-file-filters {
    display: grid;
    gap: 0.65rem;
    padding-top: 0.15rem;
}

.advanced-file-filter-heading,
.file-index-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.advanced-file-filter-heading > span,
.advanced-file-filter-field > span,
.advanced-file-filter-field > legend {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.compact-icon-btn {
    flex: 0 0 auto;
    width: 1.8rem;
    height: 1.8rem;
    color: var(--text-secondary);
}

.advanced-file-filter-field {
    display: grid;
    min-width: 0;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    border: 0;
}

#file-content-filter-input {
    width: 100%;
    min-width: 0;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font: 0.8rem var(--font-ui);
}

#file-content-filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(94, 106, 210, 0.18);
}

.file-user-filter-options {
    display: grid;
    max-height: 8.5rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-tertiary);
}

.file-user-filter-option {
    display: grid;
    grid-template-columns: 1rem minmax(0, 1fr);
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
}

.file-user-filter-option + .file-user-filter-option {
    border-top: 1px solid var(--border);
}

.file-user-filter-option input {
    width: 0.9rem;
    height: 0.9rem;
    margin: 0;
    accent-color: var(--accent);
}

.file-user-filter-option span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.file-user-filter-empty {
    padding: 0.65rem 0.55rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.file-user-match-mode {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
}

.file-user-match-mode button {
    min-width: 0;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font: 600 0.74rem var(--font-ui);
    cursor: pointer;
}

.file-user-match-mode button.active {
    border-color: var(--accent);
    background-color: rgba(94, 106, 210, 0.18);
    color: var(--text-primary);
}

.file-index-status-copy {
    display: grid;
    flex: 1;
    min-width: 0;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

#file-index-progress {
    width: 100%;
    height: 0.3rem;
    accent-color: var(--accent);
}

#file-filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(94, 106, 210, 0.18);
}

.file-format-filter {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.3rem;
}

.file-format-filter-btn {
    display: inline-flex;
    width: 100%;
    min-width: 0;
    height: 2.1rem;
    align-items: center;
    justify-content: center;
    padding: 0.28rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}

.file-format-filter-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.file-format-filter-btn.active {
    border-color: var(--accent);
    background-color: rgba(94, 106, 210, 0.18);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.file-format-filter-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.file-format-filter-btn .format-badge {
    width: 1.45rem;
    height: 1.45rem;
    padding: 0;
    border-radius: 0;
    background-color: transparent;
}

.file-format-filter-all-icon {
    display: block;
    width: 1.1rem;
    height: 1.1rem;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background-color 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-action,
.user-item-action {
    width: 1.75rem;
    height: 1.75rem;
    flex: 0 0 1.75rem;
    color: var(--text-secondary);
    opacity: 0;
}

.file-item:hover .file-item-action,
.file-item:focus-within .file-item-action,
.user-item:hover .user-item-action,
.user-item:focus-within .user-item-action {
    opacity: 1;
}

.file-item-action:hover,
.user-item-action:hover {
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

.file-item:hover {
    background-color: var(--bg-tertiary);
}

.file-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background-color: var(--bg-tertiary);
}

.file-item.file-filter-hidden {
    display: none;
}

.file-item.selected {
    background-color: rgba(94, 106, 210, 0.15);
    color: var(--accent);
    font-weight: 500;
}

/* --- Log Viewer --- */
#log-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background-color: var(--bg-primary);
    min-width: 0;
}

.open-tabs-bar {
    min-height: 36px;
    display: flex;
    align-items: end;
    gap: 0.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.35rem 0.5rem 0;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.open-tab {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 110px;
    max-width: 210px;
    padding: 0 0.35rem 0 0.65rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--text-secondary);
    background-color: transparent;
    flex-shrink: 0;
    cursor: pointer;
}

.open-tab:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.open-tab.active {
    background-color: var(--bg-primary);
    border-color: var(--border);
    color: var(--text-primary);
}

.open-tab.preview .open-tab-title {
    font-style: italic;
}

.open-tab-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 600;
}

.open-tab-close {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
}

.open-tab-close:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.viewer-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.header-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0 1.5rem 1rem 1.5rem;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 220px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    color: var(--text-secondary);
}

#search-input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-ui);
    transition: all 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(94, 106, 210, 0.2);
}

.date-jump select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-ui);
    cursor: pointer;
    min-width: 180px;
}

.header-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.channel-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.header-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-loading-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 0.35rem;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: previewSpin 0.75s linear infinite;
    opacity: 0.85;
}

@keyframes previewSpin {
    to { transform: rotate(360deg); }
}

.format-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0.15rem;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.08);
    user-select: none;
}

.format-badge svg,
.format-badge img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#active-format-badge {
    width: 3.35rem;
    height: 2.75rem;
    padding: 0.05rem;
    border-radius: 8px;
}

#active-format-badge.format-mirc {
    background-color: transparent;
    filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.45)) drop-shadow(0 10px 16px rgba(0, 0, 0, 0.32));
}

#active-format-badge.format-icq {
    width: 3rem;
    height: 3rem;
    background-color: transparent;
    filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.42)) drop-shadow(0 10px 16px rgba(0, 0, 0, 0.26));
}

#active-format-badge.format-mirc svg,
#active-format-badge.format-icq svg {
    overflow: visible;
}

:root[data-theme="light"] .format-badge {
    background-color: rgba(31, 35, 40, 0.06);
}

:root[data-theme="light"] #active-format-badge.format-mirc {
    background-color: transparent;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5)) drop-shadow(0 8px 14px rgba(31, 35, 40, 0.24));
}

:root[data-theme="light"] #active-format-badge.format-icq {
    background-color: transparent;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.42)) drop-shadow(0 8px 14px rgba(31, 35, 40, 0.2));
}

.file-format-badge {
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0.1rem;
}

.tab-format-badge {
    flex: 0 0 auto;
    width: 1.2rem;
    height: 1.2rem;
    padding: 0.08rem;
}

.format-mirc {
    background-color: rgba(47, 111, 214, 0.16);
}

.format-msn {
    background-color: rgba(31, 157, 85, 0.16);
}

.format-icq {
    background-color: rgba(210, 139, 22, 0.16);
}

.format-text {
    color: var(--text-secondary);
    background-color: rgba(160, 160, 160, 0.12);
}

.header-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
}

.header-icon-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    background-color: var(--bg-tertiary);
}

.header-icon-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.1s;
}

.icon-btn {
    padding: 0.5rem;
}

.icon-btn:hover {
    background-color: var(--bg-tertiary);
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    background-color: var(--bg-tertiary);
}

.language-picker {
    position: relative;
    min-width: 148px;
    flex: 0 0 148px;
}

.language-picker-trigger {
    width: 100%;
    height: 38px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    gap: 0.55rem;
    justify-content: flex-start;
}

.language-picker-trigger:hover,
.language-picker.open .language-picker-trigger {
    color: var(--text-primary);
    border-color: var(--accent);
}

.language-picker-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(94, 106, 210, 0.2);
}

.language-picker-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.language-picker-chevron {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.15s ease;
}

.language-picker.open .language-picker-chevron {
    transform: rotate(225deg) translate(-1px, -1px);
}

.language-picker-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 100;
    width: 190px;
    padding: 0.3rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}

.language-picker.open .language-picker-menu {
    display: block;
}

.language-picker.compact {
    min-width: 48px;
    flex-basis: 48px;
}

.language-picker.compact .language-picker-trigger {
    padding: 0.45rem 0.5rem;
    gap: 0.35rem;
    justify-content: center;
}

.language-picker.compact .language-picker-label {
    display: none;
}

.language-picker.compact .language-picker-chevron {
    display: none;
}

.language-picker.compact .language-picker-menu {
    width: 48px;
}

.language-picker.compact .language-picker-option {
    padding: 0.45rem;
    justify-content: center;
}

.language-picker.compact .language-picker-option span:not(.language-flag),
.language-picker.compact .language-picker-option[aria-selected="true"]::after {
    display: none;
}

.language-picker-option {
    position: relative;
    width: 100%;
    min-height: 36px;
    padding: 0.45rem 1.8rem 0.45rem 0.55rem;
    gap: 0.65rem;
    justify-content: flex-start;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.language-picker-option:hover,
.language-picker-option:focus-visible {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.language-picker-option[aria-selected="true"] {
    color: var(--text-primary);
    background-color: rgba(94, 106, 210, 0.16);
}

.language-picker-option[aria-selected="true"]::after {
    content: '✓';
    position: absolute;
    right: 0.65rem;
    color: var(--accent-hover);
    font-weight: 700;
}

.language-flag {
    display: block;
    width: 24px;
    height: 16px;
    flex: 0 0 24px;
    object-fit: cover;
    background-color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .language-flag {
    border-color: rgba(0, 0, 0, 0.25);
}

.theme-toggle-btn:hover {
    color: var(--accent-hover);
}

.toggle-btn {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    font-size: 0.9rem;
}

.toggle-btn:hover {
    background-color: var(--border);
}

/* --- Messages Container --- */
#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    scroll-behavior: smooth;
}

.pending-date-state {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pending-date-state .preview-loading-spinner {
    width: 14px;
    height: 14px;
    margin-left: 0;
    border-width: 2px;
}

.empty-search-state {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.message-row {
    display: flex;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.message-row:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

:root[data-theme="light"] .message-row:hover {
    background-color: rgba(49, 94, 207, 0.07);
}

.timestamp {
    color: var(--msg-timestamp);
    min-width: 75px;
    flex-shrink: 0;
    user-select: none;
}

.content {
    flex: 1;
    word-break: break-word;
}

.content a {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.content a:hover {
    color: #ffffff;
}

.msn-emoticon {
    display: inline-block;
    height: 19px;
    margin: 0 1px;
    object-fit: contain;
    vertical-align: -4px;
}

.username {
    font-weight: 600;
    margin-right: 0.5rem;
}

.message-row.no-timestamp {
    padding-left: 0.75rem;
}

.message-row.no-timestamp .username {
    display: inline-block;
    min-width: 9.5rem;
    margin-right: 0.75rem;
}

/* Colors for different users (assigned dynamically) */
.user-color-1 { color: #e06c75; }
.user-color-2 { color: #98c379; }
.user-color-3 { color: #e5c07b; }
.user-color-4 { color: #61afef; }
.user-color-5 { color: #56b6c2; }

/* Special message types */
.message-row.system {
    color: var(--msg-system);
    font-family: var(--font-ui);
    font-style: italic;
    justify-content: center;
    margin: 0.5rem 0;
}
.message-row.system .timestamp { display: none; }
.message-row.system .content { text-align: center; }

.message-row.plain .content {
    white-space: pre-wrap;
}

.message-row.action .content {
    color: var(--msg-action);
    font-style: italic;
}

.date-separator {
    position: sticky;
    top: 0;
    align-self: center;
    margin: 1rem 0 0.75rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-ui);
    z-index: 1;
}

/* --- Playback Controls --- */
.playback-bar {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.playback-bar button:disabled,
.playback-bar input:disabled,
.playback-bar select:disabled {
    cursor: default;
    opacity: 0.42;
}

.primary-btn {
    background-color: var(--accent);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.1s, background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}

.primary-btn:active {
    transform: scale(0.95);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

#speed-select {
    min-width: 4.25rem;
    font-family: var(--font-mono);
    font-weight: 600;
}
/* --- Right Sidebar (User List) --- */
#user-sidebar {
    width: var(--user-sidebar-width);
    min-width: 280px;
    max-width: 45vw;
    flex: 0 0 var(--user-sidebar-width);
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    transition: width 0.12s ease, flex-basis 0.12s ease;
}

#user-sidebar.hidden {
    display: none !important;
}

.user-sidebar-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -5px;
    width: 10px;
    cursor: col-resize;
    touch-action: none;
    z-index: 12;
}

.user-sidebar-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 4px;
    width: 2px;
    height: 44px;
    border-radius: 999px;
    background-color: var(--bg-tertiary);
    transform: translateY(-50%);
}

.user-sidebar-resizer:hover::after,
.user-sidebar-resizer:focus-visible::after,
body.resizing-user-sidebar .user-sidebar-resizer::after {
    background-color: var(--accent);
}

body.resizing-user-sidebar {
    cursor: col-resize;
    user-select: none;
}

body.resizing-user-sidebar #user-sidebar {
    transition: none;
}

.side-tabs-shell {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.side-tabs {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    padding: 0.5rem;
}

.side-tab {
    white-space: nowrap;
    overflow-wrap: normal;
    padding: 0.45rem 0.5rem;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

.side-tab:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.side-tab.active {
    background-color: var(--accent);
    color: #ffffff;
}

.side-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.side-panel.active {
    display: flex;
    flex-direction: column;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-search-summary {
    cursor: default;
}

.user-search-match-count {
    min-width: 1.5rem;
    padding: 0.08rem 0.3rem;
    border-radius: 4px;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    text-align: center;
}

.user-scope-toggle {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

.user-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.user-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.user-item.active-filter {
    background-color: rgba(94, 106, 210, 0.2);
    color: var(--accent);
    font-weight: bold;
}

.user-item.primary-filter {
    background-color: rgba(229, 192, 123, 0.18);
    color: #e5c07b;
    border: 1px solid rgba(229, 192, 123, 0.45);
}

.username.primary-user {
    color: #e5c07b;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.links-context {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

.links-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.link-item {
    padding: 0.6rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background-color: rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] .link-item {
    background-color: rgba(49, 94, 207, 0.035);
}

.link-date {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-bottom: 0.35rem;
}

.link-url {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
    margin-bottom: 0.55rem;
}

.link-actions {
    display: flex;
    gap: 0.4rem;
}

.link-actions a {
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 0.25rem 0.45rem;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
}

.link-actions a:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

:root[data-theme="light"] .open-tab.active {
    background-color: var(--bg-primary);
}

.empty-links {
    padding: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}
.speed-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: var(--accent);
}

/* --- Export --- */
.context-menu {
    position: fixed;
    z-index: 80;
    width: min(15rem, calc(100vw - 1rem));
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-secondary);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

.context-menu-label {
    padding: 0.4rem 0.55rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-menu button {
    width: 100%;
    min-height: 2.25rem;
    justify-content: flex-start;
    gap: 0.55rem;
    padding: 0.45rem 0.55rem;
    font-size: 0.85rem;
}

.context-menu button:hover,
.context-menu button:focus-visible {
    background-color: var(--bg-tertiary);
    outline: none;
}

.export-dialog {
    width: min(31rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.export-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.62);
}

.export-dialog-shell {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
}

.export-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.2rem 0.95rem;
    border-bottom: 1px solid var(--border);
}

.export-dialog-header h2 {
    font-size: 1.05rem;
    line-height: 1.35;
}

.export-dialog-header p {
    max-width: 25rem;
    margin-top: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
}

.export-dialog-body {
    display: grid;
    gap: 1rem;
    padding: 1.1rem 1.2rem;
    overflow-y: auto;
}

.export-field,
.export-format-field {
    display: grid;
    gap: 0.45rem;
    border: 0;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

.export-field select {
    width: 100%;
    min-height: 2.4rem;
}

.export-format-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.export-format-options label {
    position: relative;
    min-width: 0;
    cursor: pointer;
}

.export-format-options label + label {
    border-left: 1px solid var(--border);
}

.export-format-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.export-format-options span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.export-format-options input:checked + span {
    background-color: var(--accent);
    color: #ffffff;
}

.export-format-options input:focus-visible + span {
    outline: 2px solid var(--accent-hover);
    outline-offset: -2px;
}

.export-summary {
    min-height: 1.2rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.4;
}

.export-status {
    min-height: 1rem;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.35;
}

.export-status.error {
    color: #f06a72;
}

.export-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.85rem 1.2rem 1.1rem;
    border-top: 1px solid var(--border);
}

.export-cancel-btn,
.export-confirm-btn {
    min-height: 2.35rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    font-size: 0.84rem;
    font-weight: 600;
}

.export-cancel-btn:hover {
    background-color: var(--bg-tertiary);
}

.export-confirm-btn {
    gap: 0.45rem;
    border-color: var(--accent);
    background-color: var(--accent);
    color: #ffffff;
}

.export-confirm-btn:hover {
    border-color: var(--accent-hover);
    background-color: var(--accent-hover);
}

.export-confirm-btn:disabled,
.export-cancel-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

/* --- App information dialogs --- */
.info-dialog {
    width: min(35rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.info-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.62);
}

.info-dialog-shell {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
}

.info-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.info-dialog-header h2 {
    font-size: 1rem;
    line-height: 1.35;
}

.info-dialog-header p {
    margin-top: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.4;
}

.info-dialog-body {
    padding: 1.05rem 1.1rem 1.15rem;
    overflow-y: auto;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.55;
}

.help-dialog {
    width: min(46rem, calc(100vw - 2rem));
}

.help-sections {
    display: grid;
    gap: 0.55rem;
    padding-top: 0.8rem;
    padding-bottom: 1rem;
}

.help-quick-start {
    margin-bottom: 0.2rem;
    padding: 0.85rem 0.95rem;
    border-left: 3px solid var(--accent);
    background-color: var(--bg-tertiary);
}

.help-quick-start ol {
    display: grid;
    gap: 0.38rem;
    margin: 0.45rem 0 0;
    padding-left: 1.25rem;
}

.help-sections h3,
.help-sections summary {
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 600;
}

.help-sections details {
    border-bottom: 1px solid var(--border);
}

.help-sections summary {
    padding: 0.65rem 0.2rem;
    cursor: pointer;
    user-select: none;
}

.help-sections summary:hover {
    color: var(--accent-hover);
}

.help-sections details p {
    max-width: 68ch;
    margin: 0 0 0.85rem 1.2rem;
}

.help-sections details[open] summary {
    color: var(--accent-hover);
}

@media (max-width: 620px) {
    .help-sections details p {
        margin-left: 0.2rem;
    }
}

.blog-posts {
    display: grid;
    gap: 0;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.blog-posts article {
    padding: 0.9rem 0;
}

.blog-posts article + article {
    border-top: 1px solid var(--border);
}

.blog-post-label {
    display: block;
    margin-bottom: 0.28rem;
    color: var(--accent-hover);
    font: 600 0.68rem/1.3 var(--font-mono);
    text-transform: uppercase;
}

.blog-posts h3 {
    margin-bottom: 0.28rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.resource-links {
    display: grid;
    gap: 0;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.resource-links a {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
    color: var(--text-primary);
    text-decoration: none;
}

.resource-links a + a {
    border-top: 1px solid var(--border);
}

.resource-links a:hover,
.resource-links a:focus-visible {
    color: var(--accent-hover);
    outline: none;
}

@media (max-width: 760px) {
    .app-header {
        min-height: 48px;
        gap: 0.35rem;
        padding: 0.35rem 0.55rem;
    }

    .app-brand {
        gap: 0.4rem;
    }

    .app-brand-mark {
        width: 1.85rem;
        height: 1.85rem;
        flex-basis: 1.85rem;
    }

    .app-brand-title {
        max-width: 6.25rem;
        font-size: 0.88rem;
    }

    .app-nav {
        gap: 0.1rem;
    }

    .app-nav-button {
        width: 2.15rem;
        height: 2.15rem;
        min-height: 2.15rem;
        justify-content: center;
        padding: 0;
    }

    .app-nav-button span {
        display: none;
    }

    .app-header-actions {
        gap: 0.3rem;
    }

    .app-header .language-picker {
        min-width: 44px;
        flex-basis: 44px;
    }

    .app-header .language-picker-trigger {
        padding: 0.4rem;
        justify-content: center;
    }

    .app-header .language-picker-label,
    .app-header .language-picker-chevron {
        display: none;
    }

    .app-header .language-picker-menu {
        width: 12rem;
    }

    .app-footer {
        min-height: 32px;
        gap: 0.35rem;
        padding: 0.25rem 0.55rem;
    }

    .app-footer-brand,
    .coming-soon-label {
        display: none;
    }

    .app-footer-links {
        width: 100%;
        justify-content: center;
    }

    #drop-zone {
        align-items: flex-start;
        padding: 1rem 0.75rem;
    }

    .drop-content {
        margin: auto 0;
        padding: 1.5rem 1rem;
    }

    #sidebar,
    #user-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        width: min(92vw, 23rem);
        min-width: 0;
        max-width: none;
        z-index: 42;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
        transition: transform 0.18s ease;
    }

    #sidebar {
        left: 0;
        transform: translateX(-105%);
    }

    #user-sidebar {
        right: 0;
        left: auto;
        flex-basis: auto;
        transform: translateX(105%);
    }

    #sidebar.mobile-open,
    #user-sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-resizer,
    .user-sidebar-resizer {
        display: none;
    }

    .mobile-panel-close {
        width: 2.2rem;
        height: 2.2rem;
        display: inline-flex;
        flex: 0 0 2.2rem;
    }

    .mobile-panel-backdrop:not(.hidden) {
        position: absolute;
        inset: 0;
        display: block;
        z-index: 40;
        border: 0;
        border-radius: 0;
        background-color: rgba(0, 0, 0, 0.52);
    }

    .mobile-workspace-button:not(.hidden) {
        display: inline-flex;
    }

    .header-top {
        align-items: flex-start;
        gap: 0.6rem;
        padding: 0.65rem 0.7rem;
    }

    .header-info {
        min-width: 0;
        flex: 1;
    }

    .header-info h2 {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .header-controls {
        flex: 0 0 auto;
        gap: 0.25rem;
    }

    .header-controls .toggle-btn {
        width: 2.25rem;
        height: 2.25rem;
        justify-content: center;
        padding: 0;
    }

    .header-controls .toggle-btn span {
        display: none;
    }

    .header-controls .icon-btn,
    .header-icon-btn {
        width: 2.25rem;
        height: 2.25rem;
        flex: 0 0 2.25rem;
    }

    .header-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.55rem;
        padding: 0 0.7rem 0.7rem;
    }

    .search-box {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .date-jump,
    .date-jump select {
        width: 100%;
        min-width: 0;
    }

    .date-jump {
        grid-column: 1 / -1;
    }

    .open-tab {
        min-width: 9rem;
        max-width: 11rem;
    }

    .info-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .info-dialog-shell {
        max-height: calc(100dvh - 1rem);
    }
}

@media (max-width: 620px) {
    .file-item-action,
    .user-item-action {
        opacity: 1;
    }

    .export-dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
