/* ===== Search input ===== */
#search_form { position: relative; }
#search_value { font-size: 15px; height: 56px; background-image: none; transition: all 0.3s ease; }

/* ===== Sidebar search dropdown ===== */
.sidebar-search-dropdown {
    display: none;
    position: fixed;
    background: #fff;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 320px;
    overflow-y: auto;
    z-index: 99999;
}
.ssd-item {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--color-text-1);
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.ssd-item:last-child { border-bottom: none; }
.ssd-item:hover { background: #f5f5f5; }
.ssd-title { font-size: 14px; font-weight: 600; }
.ssd-text { font-size: 12px; color: #888; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ssd-empty { padding: 20px; text-align: center; color: #aaa; font-size: 14px; }
.sidebar-search-dropdown mark { background: rgba(255,78,106,0.15); color: var(--color-primary); font-weight: 600; padding: 0 2px; border-radius: 2px; }
.sidebar-search-dropdown::-webkit-scrollbar { width: 4px; }
.sidebar-search-dropdown::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* Dark mode - sidebar dropdown */
html.dark-mode .sidebar-search-dropdown { background: #2a2a2a; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
html.dark-mode .ssd-item { color: #ddd; border-bottom-color: rgba(255,255,255,0.06); }
html.dark-mode .ssd-item:hover { background: rgba(255,255,255,0.06); }
html.dark-mode .ssd-text { color: #888; }
html.dark-mode .ssd-empty { color: #666; }
html.dark-mode .sidebar-search-dropdown::-webkit-scrollbar-thumb { background: #555; }

/* ===== Missing icon fix ===== */
.nexmoe #nexmoe-header .nexmoe-list .nexmoe-list-item svg.mdui-list-item-icon {
    color: #9ca2a8;
}
.nexmoe #nexmoe-header .nexmoe-list .nexmoe-list-item.true svg.mdui-list-item-icon {
    color: #fff;
}

/* ===== Friend cards ===== */
.friend-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 8px 0;
}
.friend-item {
    display: flex;
    align-items: center;
    width: calc(50% - 8px);
    padding: 14px;
    border-radius: var(--radius);
    background: var(--color-card);
    box-shadow: 0 2px 12px var(--color-shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    overflow: hidden;
}
.friend-item:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 6px 20px var(--color-shadow);
}
.friend-avatar {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 14px;
}
.friend-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.friend-info {
    flex: 1;
    min-width: 0;
}
.friend-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.friend-desc {
    font-size: 13px;
    color: var(--color-text-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
@media (max-width: 600px) {
    .friend-item {
        width: 100%;
    }
}

/* ===== Search overlay ===== */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}
.search-overlay.active {
    display: flex;
}
.search-modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 600px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    animation: searchSlideIn 0.25s ease;
}
@keyframes searchSlideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.search-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    gap: 12px;
}
.search-icon {
    flex-shrink: 0;
    color: #999;
}
.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    color: #222;
    background: transparent;
}
.search-input::placeholder { color: #aaa; }
.search-close {
    width: 30px;
    height: 30px;
    border: none;
    background: #f0f0f0;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.search-close:hover { background: #e0e0e0; color: #333; }

.search-results {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
}
.search-results::-webkit-scrollbar { width: 5px; }
.search-results::-webkit-scrollbar-thumb { background: #ccc; border-radius: 5px; }

.search-count {
    color: #999;
    font-size: 13px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}
.search-result-item {
    display: block;
    padding: 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: #f8f8f8;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}
.search-result-item:hover {
    background: #f0f0f0;
    transform: translateX(3px);
    color: #333;
}
.search-result-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 6px;
}
.search-result-content {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}
.search-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.search-result-tag {
    font-size: 11px;
    color: #888;
    background: #eee;
    padding: 2px 8px;
    border-radius: 4px;
}
.search-empty {
    text-align: center;
    color: #aaa;
    padding: 40px 20px;
    font-size: 15px;
}
.search-results mark {
    background: rgba(255, 78, 106, 0.15);
    color: var(--color-primary);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* Search overlay - dark mode */
html.dark-mode .search-modal {
    background: #232323;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
html.dark-mode .search-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
html.dark-mode .search-icon { color: #888; }
html.dark-mode .search-input { color: #eee; }
html.dark-mode .search-input::placeholder { color: #666; }
html.dark-mode .search-close { background: #333; color: #888; }
html.dark-mode .search-close:hover { background: #444; color: #ddd; }
html.dark-mode .search-count { color: #777; border-bottom-color: rgba(255,255,255,0.06); }
html.dark-mode .search-result-item { background: #1a1a1a; color: #ddd; }
html.dark-mode .search-result-item:hover { background: #2a2a2a; color: #ddd; }
html.dark-mode .search-result-content { color: #999; }
html.dark-mode .search-result-tag { background: rgba(255,255,255,0.08); color: #aaa; }
html.dark-mode .search-empty { color: #666; }
html.dark-mode .search-results::-webkit-scrollbar-thumb { background: #555; }
html.dark-mode .search-results mark {
    background: rgba(255, 78, 106, 0.25);
    color: #ff6b81;
}

/* ===== Slide toggle ===== */
.nexmoe-switch-theme {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 999;
}
.theme-toggle-container {
    position: relative;
    width: 100%;
    height: 50px;
    background: #e8eaed;
    border-radius: 25px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px var(--color-shadow);
}
.theme-slider {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 42px;
    height: 42px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1;
}
html.dark-mode .theme-toggle-container {
    background: #404456;
}
html.dark-mode .theme-slider {
    left: calc(100% - 46px);
    background: #3a3a4e;
}
.theme-icon {
    position: absolute;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-icon.sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
.theme-icon.moon {
    opacity: 0;
    transform: scale(0.6) rotate(-90deg);
}
html.dark-mode .theme-icon.sun {
    opacity: 0;
    transform: scale(0.6) rotate(90deg);
}
html.dark-mode .theme-icon.moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
.theme-toggle-container:hover {
    transform: scale(1.03);
}
.theme-toggle-container:active {
    transform: scale(0.98);
}

/* ===== Dark mode ===== */
html.dark-mode {
    --color-card: #2b2b2b;
    --color-text-1: #fff;
    --color-text-2: #ccc;
    --color-text-3: #bbb;
    --color-shadow: rgba(0,0,0,0.5);
}
body { transition: background 0.5s ease, color 0.3s ease; }
html.dark-mode body {
    background-color: #1a1a1a !important;
    background-image: linear-gradient(rgba(0,0,0,0.65), rgba(0,0,0,0.65)), url("/images/bg2.jpg") !important;
    background-attachment: fixed !important; background-size: cover !important; color: #eee !important;
}
html.dark-mode .nexmoe-bg { filter: brightness(0.4); }
html.dark-mode .mdui-appbar {
    background-color: rgba(20,20,20,0.8) !important;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
}
html.dark-mode .mdui-toolbar .mdui-btn-icon,
html.dark-mode .mdui-toolbar .mdui-btn-icon i { color: rgba(255,255,255,0.9) !important; }
html.dark-mode .nexmoe-drawer,
html.dark-mode .nexmoe-item,
html.dark-mode .nexmoe-widget,
html.dark-mode .nexmoe-widget-wrap,
html.dark-mode .nexmoe-toc {
    background-color: rgba(35,35,35,0.8) !important;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    border-radius: var(--radius) !important; border: 1px solid rgba(255,255,255,0.03) !important;
}
html.dark-mode .nexmoe-primary,
html.dark-mode .nexmoe-post-container {
    background-color: rgba(35,35,35,0.8) !important;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255,255,255,0.03) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    border-radius: var(--radius) !important;
}
html.dark-mode .nexmoe-post {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
html.dark-mode .nexmoe-post-container {
    padding-left: 0 !important;
    padding-right: 0 !important;
}
html.dark-mode .comments,
html.dark-mode #giscus-container,
html.dark-mode .nexmoe-post-footer {
    background-color: rgba(35,35,35,0.8) !important; backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    border: 1px solid rgba(255,255,255,0.03) !important;
    border-top: 1px solid rgba(255,255,255,0.05) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
}
/* ===== FIX: 只讓文章變寬 ===== */
html.dark-mode .nexmoe-post {
    max-width: none !important;
    width: 100% !important;
}
html.dark-mode .nexmoe-post-container {
    max-width: none !important;
}
html.dark-mode body, html.dark-mode h1, html.dark-mode h2, html.dark-mode h3,
html.dark-mode h4, html.dark-mode h5, html.dark-mode h6,
html.dark-mode p, html.dark-mode span, html.dark-mode li, html.dark-mode label,
html.dark-mode .nexmoe-widget-title,
html.dark-mode .nexmoe-list-item .mdui-list-item-content,
html.dark-mode .nexmoe-post-content, html.dark-mode .nexmoe-post-content *,
html.dark-mode .article-entry, html.dark-mode .article-entry * {
    color: rgba(255,255,255,0.9) !important;
}
html.dark-mode a { color: var(--color-primary) !important; }
html.dark-mode a:hover { filter: brightness(1.2); }
html.dark-mode .nexmoe-widget-content { background: transparent !important; border: none !important; box-shadow: none !important; }
html.dark-mode #search_value,
html.dark-mode .nexmoe-widget-content input {
    background: rgba(255,255,255,0.05) !important; border: 1px solid rgba(255,255,255,0.1) !important;
    color: #fff !important; border-radius: 8px !important;
}
html.dark-mode .nexmoe-count div { color: #aaa !important; }
html.dark-mode .nexmoe-count div span { color: #fff !important; }
html.dark-mode .nexmoe-post-meta, html.dark-mode .nexmoe-post-meta a { color: #888 !important; }
html.dark-mode code { background-color: rgba(255,255,255,0.1) !important; color: #ff4e6a !important; }
html.dark-mode iframe.giscus-frame { background: transparent !important; }
html.dark-mode .nexmoe-social a { color: rgba(255,255,255,0.8) !important; background-color: rgba(255,255,255,0.08) !important; }
html.dark-mode .nexmoe-page-nav > * { background: rgba(255,255,255,0.1); color: #ccc; }
html.dark-mode .nexmoe-page-nav .current { color: #fff; background: var(--color-primary); }
html.dark-mode .nexmoe-copyright, html.dark-mode .nexmoe-copyright a { color: rgba(255,255,255,0.5) !important; }
html.dark-mode .archive-list-count { color: #aaa !important; }
html.dark-mode .mdui-fab { background-color: rgba(35,35,35,0.9) !important; color: #fff !important; }
html.dark-mode .nexmoe-archives .tagcloud a { color: rgba(255,255,255,0.85) !important; }
html.dark-mode .nexmoe-post-cover h1 { color: #fff !important; }
html.dark-mode .nexmoe-post {
    max-width: 900px !important;
    width: 100% !important;
    margin: 0 auto !important;
}
/* ===== FORCE 全部撐寬 ===== */
html.dark-mode .nexmoe-primary,
html.dark-mode .nexmoe-post-container {
    max-width: none !important;
    width: 100% !important;
}

/* 讓文章卡片跟留言一樣寬 */
html.dark-mode .nexmoe-post {
    width: 100% !important;
}