@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic/OpenDyslexic-Regular.otf") format("opentype");
    font-weight: normal;
}

@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic/OpenDyslexic-Bold.otf") format("opentype");
    font-weight: bold;
}

/* ========== Layout ========== */
:root {
    --sidebar-width: 260px;
}

body {
    overflow: hidden;
    height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    flex-shrink: 0;
    transition: background 0.2s;
}

[data-bs-theme="light"] #sidebar {
    background: #f5f5f5;
}

[data-bs-theme="dark"] #sidebar {
    background: #16213e;
}

[data-bs-theme="dark"] body {
    background: #1a1a2e;
}

#content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ========== Sidebar ========== */
.sidebar-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.folder-item, .feed-item, .nav-item {
    padding: 0.35rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    user-select: none;
}

.folder-item:hover, .feed-item:hover, .nav-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .folder-item:hover,
[data-bs-theme="dark"] .feed-item:hover,
[data-bs-theme="dark"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.feed-item {
    padding-left: 2rem;
}

.folder-toggle {
    cursor: pointer;
    margin-right: 0.25rem;
}

.unread-count {
    font-size: 0.75rem;
    color: var(--bs-secondary);
    margin-left: auto;
    padding-left: 0.5rem;
}

.nav-item.active, .folder-item.active, .feed-item.active {
    background: var(--bs-primary);
    color: white;
}

/* ========== Article List ========== */
.article-toolbar {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.article-list {
    flex: 1;
    overflow-y: auto;
}

.article-row {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.article-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="dark"] .article-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.article-row.read {
    opacity: 0.55;
}

[data-bs-theme="dark"] .article-row.read {
    opacity: 0.45;
}

.article-row.selected {
    background: rgba(var(--bs-primary-rgb), 0.08);
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
}

.article-source {
    width: 140px;
    flex-shrink: 0;
    color: var(--bs-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-snippet {
    color: var(--bs-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.article-time {
    flex-shrink: 0;
    color: var(--bs-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ========== Expanded Article ========== */
.article-expanded {
    padding: 1.5rem;
    border-bottom: 2px solid var(--bs-border-color);
    display: none;
}

.article-expanded.show {
    display: block;
}

.article-expanded .article-meta {
    color: var(--bs-secondary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.article-expanded .article-body {
    line-height: 1.7;
    max-width: 720px;
}

.article-expanded .article-body img {
    max-width: 100%;
    height: auto;
}

.article-expanded .article-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bs-border-color);
    display: flex;
    gap: 0.5rem;
}

/* ========== OpenDyslexic + Bionic Reading ========== */
.opendyslexic .article-body {
    font-family: "OpenDyslexic", sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    line-height: 1.8;
}

.bionic b {
    font-weight: 700;
}

/* ========== Bulk Select ========== */
.feed-item.bulk-selected {
    background: rgba(var(--bs-primary-rgb), 0.15);
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
}

.bulk-action-bar {
    padding: 0.5rem;
    border-top: 2px solid var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.08);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.bulk-action-bar .bulk-count {
    font-weight: 600;
    margin-right: auto;
}

/* ========== Drag and Drop ========== */
.feed-item[draggable="true"] {
    cursor: grab;
}

.feed-item[draggable="true"]:active {
    cursor: grabbing;
}

.feed-item.dragging {
    opacity: 0.4;
}

.folder-item.drag-over,
.drop-zone-uncategorized.drag-over {
    background: rgba(var(--bs-primary-rgb), 0.15) !important;
    outline: 2px dashed var(--bs-primary);
    outline-offset: -2px;
}

.drop-zone-uncategorized {
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    color: var(--bs-secondary);
    text-align: center;
    display: none;
}

.drop-zone-uncategorized.visible {
    display: block;
}

/* ========== Mobile ========== */
@media (max-width: 767.98px) {
    #sidebar {
        width: 100%;
    }

    .article-source {
        width: 80px;
    }

    .article-snippet {
        display: none;
    }
}

/* ========== Keyboard shortcut overlay ========== */
.shortcut-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.shortcut-overlay.show {
    display: flex;
}

.shortcut-overlay table {
    background: var(--bs-body-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    min-width: 400px;
}

.shortcut-overlay kbd {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: var(--bs-tertiary-bg);
    border-radius: 0.25rem;
    font-size: 0.85rem;
}

/* ========== Speed Reading Overlay ========== */
.speed-read-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none;
    flex-direction: column;
}

.speed-read-overlay.show {
    display: flex;
}

.speed-read-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    background: var(--bs-body-bg);
}

.speed-read-toolbar {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.speed-read-settings {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.speed-read-settings label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--bs-secondary);
    white-space: nowrap;
}

.speed-read-settings select,
.speed-read-settings input[type="number"] {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.speed-read-settings input[type="number"] {
    width: 5rem;
}

.speed-read-text {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    line-height: 2;
    font-size: 1.15rem;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.speed-read-text h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.speed-read-text .sr-meta {
    color: var(--bs-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.speed-read-text .sr-paragraph {
    margin-bottom: 1rem;
}

.speed-read-text .sr-word {
    display: inline;
    position: relative;
    border-radius: 2px;
}

/* Cue type: underline */
.sr-word.sr-cue-underline {
    border-bottom-style: solid;
}

/* Cue type: bold-underline */
.sr-word.sr-cue-bold-underline {
    font-weight: bold;
    border-bottom-style: solid;
}

/* Cue type: pipes — uses ::before/::after */
.sr-word.sr-cue-pipes-first::before {
    content: "|";
    font-weight: bold;
}

.sr-word.sr-cue-pipes-last::after {
    content: "|";
    font-weight: bold;
}

/* Cue type: vertical-line and cursor — a positioned element */
.speed-read-cue-line {
    position: absolute;
    top: 0;
    pointer-events: none;
    z-index: 1;
}

/* ========== Speed Reading Controls ========== */
.speed-read-controls {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.speed-read-buttons {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.speed-read-progress-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.speed-read-progress {
    flex: 1;
    height: 6px;
    background: var(--bs-border-color);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.speed-read-progress-bar {
    height: 100%;
    background: var(--bs-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.speed-read-position {
    font-size: 0.75rem;
    color: var(--bs-secondary);
    white-space: nowrap;
    min-width: 5rem;
    text-align: right;
}

/* ========== Speed Reading: OpenDyslexic ========== */
.speed-read-text.opendyslexic {
    font-family: "OpenDyslexic", sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    line-height: 2.2;
}

.speed-read-text.opendyslexic .bionic b {
    font-weight: 700;
}

/* ========== Speed Reading Mobile ========== */
@media (max-width: 767.98px) {
    .speed-read-settings {
        gap: 0.4rem;
    }

    .speed-read-text {
        padding: 1rem;
        font-size: 1rem;
    }
}
