:root {
    --primary: #FF9800;
    --primary-light: #FFB74D;
    --primary-dark: #F57C00;
    --bg-color: #F8F9FA;
    --text-main: #333333;
    --border-color: #E0E0E0;
    --radius: 16px;
    --font-scale: 1
}

body {
    margin: 0; padding: 0;
    background-color: var(--bg-color); color: var(--text-main);
    display: flex; height: 100dvh; overflow: hidden;
    font-size: calc(14px * var(--font-scale));
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale
}

#sidebar {
    width: 260px; background: #fff; border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; transition: all .3s cubic-bezier(.4, 0, .2, 1);
    z-index: 100; position: relative; flex-shrink: 0;
}

#sidebar.collapsed { width: 80px }
#sidebar.collapsed .brand-info-row, 
#sidebar.collapsed .sidebar-text, 
#sidebar.collapsed .sidebar-footer-content, 
#sidebar.collapsed .cat-badge, 
#sidebar.collapsed .sub-menu { display: none }
#sidebar.collapsed .sidebar-header img { width: 38px }
#sidebar.collapsed .sidebar-header { padding: 12px; justify-content: center; }
#sidebar.collapsed #collapse-toggle { right: 50%; transform: translateX(50%); bottom: 5px }

.sidebar-tool-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; width: 100%; margin-top: 2px; }
#sidebar.collapsed .sidebar-tool-group { display: flex; flex-direction: column-reverse; margin-top: auto; padding: 8px 0; align-items: center; gap: 8px; }
#sidebar.collapsed .font-btn { width: 58px !important; height: 32px !important; font-size: 0.95em !important; border-radius: 8px; }

#sidebar.collapsed .sidebar-footer select, 
#sidebar.collapsed .sidebar-footer .search-input, 
#sidebar.collapsed .sidebar-footer #custom-date-box, 
#sidebar.collapsed .data-fetch-box { display: none !important; }

.sidebar-header {
    padding: 14px 15px; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px;
    cursor: pointer; transition: .3s; box-shadow: 0 2px 10px rgba(0,0,0,.1); position: relative
}
.sidebar-header img { width: 42px; height: auto; transition: .3s; filter: drop-shadow(0 2px 4px rgba(0,0,0,.2)) }
.brand-info-row { display: flex; align-items: center; color: #fff; white-space: nowrap }
.brand-title-text { font-size: 1.2rem; font-weight: 900; letter-spacing: -.5px }

#collapse-toggle {
    position: absolute; right: 10px; bottom: 8px; width: 24px; height: 24px;
    background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.3);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 110; transition: .2s
}
#collapse-toggle:hover { background: rgba(255,255,255,.4) }

.category-container { flex: 1; overflow-y: auto; padding: 8px }
.category-container::-webkit-scrollbar { width: 6px }
.category-container::-webkit-scrollbar-thumb { background: #bbb; border-radius: 10px }
.category-container::-webkit-scrollbar-track { background: transparent }

.cat-item {
    padding: 10px 12px; border-radius: 12px; cursor: pointer; margin-bottom: 2px;
    transition: .2s; display: flex; align-items: center; gap: 10px;
    font-weight: 700; color: #444; border: 1px solid transparent; background: #fff
}
.cat-item i { font-size: 1.1rem; color: var(--primary); width: 20px; text-align: center }
.cat-badge { background: var(--primary); color: #fff; font-size: 10px; font-weight: 900; padding: 2px 8px; border-radius: 20px; margin-left: auto; }
.cat-item:hover { background: #fff8f0; color: var(--primary) }
.cat-item.active { background: rgba(255, 152, 0, .1); color: var(--primary-dark); border: 1px solid rgba(255, 152, 0, .2) }

.sub-menu { padding-left: 15px; overflow: hidden; max-height: 0; transition: max-height 0.3s ease-out; margin-bottom: 4px; }
.sub-menu.show { max-height: 800px; }
.sub-item {
    padding: 8px 12px; font-size: 0.9em; font-weight: 600; color: #555;
    cursor: pointer; border-radius: 10px; margin-bottom: 1px; display: flex; justify-content: space-between; align-items: center;
}
.sub-item:hover { background: #fef3c7; color: var(--primary-dark); }
.sub-item.active { color: var(--primary-dark); font-weight: 900; background: #fff7ed; }
.sub-item .cat-badge { background: #f1f5f9; color: #94a3b8; box-shadow: none; font-size: 9px; margin-left: 8px; }

.sidebar-footer { padding: 8px 12px; border-top: 1px solid #f0f0f0; background: #fafafa; display: flex; flex-direction: column; }
#content { flex: 1; overflow-y: auto; padding: 20px; position: relative; scroll-behavior: smooth; }

.filter-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; width: 100%; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; cursor: grab; user-select: none; scrollbar-width: thin; scrollbar-color: #eee transparent; }
.filter-row:active { cursor: grabbing; }
.filter-row::-webkit-scrollbar { height: 4px; }
.filter-row::-webkit-scrollbar-thumb { background: #eee; border-radius: 10px; }

.filter-btn {
    padding: 6px 14px; border-radius: 20px; font-size: .85em; font-weight: 800; background: #fff; border: 1px solid #ddd; color: #666; cursor: pointer; transition: .2s; white-space: nowrap; display: flex; align-items: center; gap: 4px;
}
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff }
.filter-btn.active.asc { background: #e6ffed; border-color: #b7eb8f; color: #52c41a; }

.font-btn {
    background: var(--primary); color: #fff; border: none; border-radius: 10px; font-weight: 900; cursor: pointer; transition: .2s;
    box-shadow: 0 2px 4px rgba(255,152,0,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 32px;
}
.font-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

.news-card {
    padding: 24px; border: 1px solid var(--border-color); border-radius: var(--radius); background: #fff; transition: all .3s; border-left: 6px solid var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,.03); margin-bottom: 20px; display: flex; flex-direction: column; position: relative
}

.tag-read, .tag-featured, .tag-ai, .score-tag, .info-badge, .expand-news-btn { font-size: 0.82em !important; font-weight: 900; padding: 3px 10px; border-radius: 6px; white-space: nowrap; line-height: 1.2; }
.score-tag, .info-badge { border-radius: 20px; padding: 5px 14px; color: #fff !important; }

.tag-read { background: #4CAF50; color: #fff; }
.tag-featured { background: #E91E63; color: #fff; box-shadow: 0 2px 4px rgba(233,30,99,0.3); }
.tag-ai { background: #8E24AA; color: #fff; box-shadow: 0 2px 4px rgba(142,36,170,0.3) }

.source-badge { font-weight: 800; color: var(--primary-dark); background: rgba(255,152,0,0.15); padding: 3px 8px; border-radius: 6px; font-size: .85em }

.news-title { font-size: 1.3em; font-weight: 800; margin: 12px 0; color: #111; line-height: 1.4 }

.ai-analysis-box { background: #fdf8f2; border: 1.5px solid #ffe4cc; border-radius: 12px; padding: 18px; line-height: 1.8; }
.ai-header-highlight { display: block; margin-top: 12px; margin-bottom: 4px; color: #F57C00; font-weight: 900; font-size: 1.05em; }
.ai-header-highlight:first-child { margin-top: 0; }

.analysis-b-section { margin-top: 15px; border-top: 1px solid #f0f0f0; padding-top: 15px; }
.cat-short-comment { display: flex; gap: 12px; align-items: center; background: #fff9f0; padding: 12px; border-radius: 12px; margin-bottom: 12px; border: 1px dashed #ffd8a8; }
.cat-short-comment img { width: 32px; height: 32px; flex-shrink: 0; }
.cat-short-comment p { font-size: 0.95em; font-weight: 700; color: #854d0e; line-height: 1.4; margin: 0; flex: 1; }

.score-badges-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.score-tag.score-index { background: #FF9800; }

.vote-container { display: flex; gap: 8px; align-items: center; }
.vote-btn { display: flex; align-items: center; gap: 4px; font-size: 0.85em; font-weight: 900; cursor: pointer; padding: 4px 8px; border-radius: 8px; transition: 0.2s; border: 1px solid transparent; color: #bbb; }
.vote-btn:hover { background: #f5f5f5; }
.vote-btn.active-like { color: #F5222D; background: #fff1f0; border-color: #ffa39e; }
.vote-btn.active-dislike { color: #52C41A; background: #f6ffed; border-color: #b7eb8f; }

.share-btn { color: #1890FF; border: 1px solid #bae7ff; background: #e6f7ff; }
.share-btn:hover { background: #bae7ff; }
.copy-card-btn { color: #8b5cf6; border: 1px solid #ddd6fe; background: #f5f3ff; }
.copy-card-btn:hover { background: #ddd6fe; }

.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; padding-top: 12px; border-top: 1px dashed #eee }
.pagination-container { display: flex; justify-content: center; align-items: center; gap: 15px; margin: 30px 0; padding-bottom: 60px; }
.page-btn { background: #fff; border: 2px solid var(--primary); color: var(--primary); padding: 8px 18px; border-radius: 20px; font-weight: 900; cursor: pointer; transition: .2s }
.page-btn:disabled { border-color: #e0e0e0; color: #ccc; cursor: not-allowed }

#mobile-header, #sidebar-overlay { display: none }
#share-modal, #admin-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 5000; display: none; align-items: center; justify-content: center; }
.share-panel, .modal-box { background: #fff; padding: 25px; border-radius: 24px; width: 90%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.share-item { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; transition: 0.2s; padding: 10px; border-radius: 12px; text-decoration: none; }
.share-item:hover { background: #f8f8f8; transform: translateY(-3px); }
.share-item i { font-size: 1.8rem; }

.float-nav { position: fixed; right: 25px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 4000; }
.nav-btn { width: 34px; height: 34px; background: rgba(255,255,255,0.9); border: 1.5px solid var(--primary); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; box-shadow: 0 3px 8px rgba(0,0,0,0.1); font-size: 1rem; }
.nav-btn:hover { background: var(--primary); color: #fff; transform: scale(1.1); }

@media (min-width: 768px) {
    #content { padding: 20px; }
    .news-card { padding: 24px; border-left: 6px solid var(--primary); margin-bottom: 20px; }
    .ai-analysis-box { padding: 18px; line-height: 1.8; }
}

@media (max-width:768px) {
    #sidebar { position: fixed; left: -280px; top: 0; bottom: 0; box-shadow: 5px 0 15px rgba(0,0,0,.1); width: 260px !important }
    #sidebar.open { left: 0 }
    #mobile-header { display: flex; background: #fff; color: var(--text-main); padding: 10px 15px; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 60; border-bottom: 1px solid var(--border-color) }
    #sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40 }
    body { flex-direction: column; height: 100dvh; }
    .float-nav { right: 15px; }
    #content { padding: 12px 6px; }
    .news-card { padding: 16px 14px; border-left: 5px solid var(--primary); margin-bottom: 16px; }
    .ai-analysis-box { padding: 14px 12px; line-height: 1.7; }
}

.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.search-input { width: 100%; border: 2px solid #fed7aa; border-radius: 10px; padding: 6px 12px; font-size: 0.8rem; font-weight: 800; color: var(--primary-dark); outline: none; background: #fff; }

.admin-controls-batch { display: none; width: 100%; gap: 10px; margin-top: 15px; border-top: 1px solid #eee; padding-top: 15px; }
.admin-active .admin-controls-batch { display: flex; }
.btn-batch { flex: 1; padding: 10px 0; border-radius: 8px; font-weight: 900; font-size: 0.9em; display: flex; justify-content: center; align-items: center; gap: 6px; cursor: pointer; transition: 0.2s; background: #fff; }

.btn-batch-del { color: #f43f5e; border: 1px solid #fecdd3; }
.btn-batch-del.active { background: #f43f5e; color: #fff; border-color: #f43f5e; }

.btn-batch-read { color: #22c55e; border: 1px solid #bbf7d0; }
.btn-batch-read.active { background: #22c55e; color: #fff; border-color: #22c55e; }

.btn-batch-feat { color: #f59e0b; border: 1px solid #fde68a; }
.btn-batch-feat.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }

.news-card.is-deleted { opacity: 0.4; filter: grayscale(100%); }
.tag-read-status { color: #333333; font-weight: 900; font-size: 1.1em; display: flex; align-items: center; }

#admin-batch-bar {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #1f2937; color: #fff; padding: 12px 24px; border-radius: 50px;
    display: none; align-items: center; gap: 20px; z-index: 5000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); white-space: nowrap; font-weight: 900; font-size: 0.9em;
}
#admin-batch-bar.show { display: flex; }
.batch-count-del { color: #f87171; }
.batch-count-read { color: #4ade80; }
.batch-count-feat { color: #fbbf24; }
.batch-cancel { color: #9ca3af; cursor: pointer; transition: 0.2s; font-size: 0.8em; }
.batch-cancel:hover { color: #fff; }
.batch-submit { background: var(--primary); padding: 8px 20px; border-radius: 20px; cursor: pointer; transition: 0.2s; color: #fff; border:none;}
.batch-submit:hover { background: var(--primary-dark); }

@media (max-width: 768px) {
    #admin-batch-bar { flex-direction: column; bottom: 10px; border-radius: 20px; gap: 10px; width: 90%; max-width: 400px; padding: 15px; }
    .bar-divider { display: none; }
}
