:root { 
    --pm-primary: #0071bc; 
    --pm-secondary: #205493; 
    --pm-accent: #f39c12; 
    --bg-gray: #f1f3f5;
    --text-primary: #2d3748;
    --border-light: #e2e8f0;
    --success: #22c55e;
    /* 新增期刊信息颜色变量 */
    --cas-1-top-q1: #006400; /* 深绿色 */
    --cas-2-q2: #2FA0ED;    /* 蓝色 */
    --cas-3-q3: #EDB12F;    /* 金黄色 */
    --cas-4-q4: #A79878;    /* 浅棕色 */
    --jif-color: #E737C6;   /* 玫红色 */
    --oa-yes: #483FA2;      /* Open Access Yes 背景色 */
}
body { 
    font-family: 'Inter', -apple-system, sans-serif; 
    background: var(--bg-gray); 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    height: 100vh;
    color: var(--text-primary);
    box-sizing: border-box;
}

* {
    box-sizing: border-box; /* 统一盒模型，解决布局重叠 */
}

.header { 
    background: var(--pm-secondary); 
    color: white; 
    padding: 0.8rem 2rem; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-content { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
    padding: 15px; 
    gap: 15px;
}

/* Sidebar 布局重构 - 核心修改 */
.sidebar { 
    width: 380px; /* 适度加宽，避免内容挤压 */
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    padding: 24px; /* 增加内边距 */
    display: flex; 
    flex-direction: column;
    gap: 16px; /* 增加元素间距 */
    overflow-y: auto; /* 内容超出时可滚动 */
}

/* 统一sidebar内的表单组样式 */
.form-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px; /* 标签和输入框间距 */
}

.form-group label {
    margin: 0; /* 重置margin */
}

.operator-buttons {
    display: flex;
    gap: 8px;
    margin: 4px 0; /* 调整按钮组间距 */
}

.operator-buttons .btn {
    flex: 1;
    padding: 8px 0; /* 统一按钮高度 */
}

.results-panel { 
    flex: 1; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    display: flex; 
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.builder-row { margin-bottom: 0; } /* 移除旧的margin，改用gap */
label { 
    display: block; 
    font-size: 11px; 
    font-weight: 700; 
    color: #94a3b8; 
    text-transform: uppercase; 
}

select, input, textarea { 
    width: 100%; 
    padding: 10px; 
    border: 1px solid var(--border-light); 
    border-radius: 4px; 
    font-size: 14px;
}

textarea { 
    height: 120px; /* 适度加高文本框 */
    font-family: monospace; 
    border: 2px solid var(--pm-primary); 
    resize: vertical; /* 允许垂直调整大小 */
}

.btn { 
    cursor: pointer; 
    border: none; 
    border-radius: 4px; 
    font-weight: 600; 
    font-size: 13px; 
    transition: 0.2s;
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 5px;
}
.btn-primary { 
    background: var(--pm-primary); 
    color: white; 
    padding: 12px 20px; /* 加大按钮内边距 */
    width: 100%; /* 搜索按钮全屏宽 */
}
.btn-outline { 
    background: white; 
    border: 1px solid var(--border-light); 
    padding: 6px 12px; 
}
.btn-outline:hover:not(:disabled) { 
    border-color: var(--pm-primary); 
    color: var(--pm-primary); 
}
.btn-success { 
    background: var(--success); 
    color: white; 
    padding: 6px 15px; 
}
.btn-filter { 
    background: #64748b; 
    color: white; 
    padding: 10px 15px; 
    margin-top: 10px; 
    width: 100%; 
}
.btn-filter:hover { 
    background: #475569; 
}

.pagination { display: flex; align-items: center; gap: 5px; }
.page-input { width: 45px; text-align: center; padding: 5px; margin: 0 5px; }

#results-list { flex: 1; overflow-y: auto; padding: 15px; background: #f8fafc; }
.article-card { 
    background: white; 
    border-radius: 8px; 
    padding: 20px; 
    margin-bottom: 12px; 
    border: 1px solid #edf2f7; 
    transition: 0.2s;
}
.article-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.article-title { color: var(--pm-primary); font-size: 16px; font-weight: 700; text-decoration: none; display: block; margin-bottom: 8px; }
.article-title:hover { text-decoration: underline; }

.meta-line { font-size: 13px; color: #64748b; margin: 5px 0; }
.tag { background: #e2e8f0; padding: 2px 6px; border-radius: 3px; font-weight: 600; color: #475569; }
.aff-box { 
    margin-top: 10px; 
    padding: 10px; 
    background: #f1f5f9; 
    border-left: 3px solid var(--pm-primary); 
    font-size: 12px; 
    border-radius: 0 4px 4px 0;
}
/* 期刊信息样式 */
.journal-info-box {
    margin-top: 8px;
    padding: 8px 12px;
    background: #F0F8FF;
    border-left: 3px solid var(--pm-accent);
    font-size: 12px;
    border-radius: 0 4px 4px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.journal-info-item {
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
    font-weight: 600;
}
.journal-info-label {
    margin-right: 4px;
}
/* 期刊信息颜色类 */
.cas-1, .top-yes, .jcr-q1 { background: var(--cas-1-top-q1); }
.cas-2, .jcr-q2 { background: var(--cas-2-q2); }
.cas-3, .jcr-q3 { background: var(--cas-3-q3); }
.cas-4, .jcr-q4 { background: var(--cas-4-q4); }
.jif { background: var(--jif-color); }
.oa-yes { background: var(--oa-yes); } /* Open Access Yes 样式 */

.spinner {
    width: 18px; height: 18px; border: 2px solid #fff;
    border-bottom-color: transparent; border-radius: 50%;
    display: inline-block; animation: rotation 1s linear infinite;
}
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.filter-section {
    margin: 8px 0; /* 调整过滤区域间距 */
    padding: 18px; /* 增加内边距 */
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 10px; /* 过滤区域内元素间距 */
}
.filter-row {
    display: flex;
    gap: 12px; /* 加大过滤输入框间距 */
}

.filter-row > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-note {
    font-size: 11px; 
    color: #94a3b8; 
    margin: 0; /* 重置margin */
}

/* 期刊数据加载状态提示 */
.journal-load-status {
    font-size: 11px;
    color: #94a3b8;
    margin: 4px 0; /* 调整间距 */
}

/* 过滤状态显示区域 */
.filter-status {
    margin-top: auto; /* 固定在底部 */
    padding-top: 16px; 
    border-top: 1px solid #eee; 
    font-size: 11px; 
    color: #94a3b8; 
    line-height: 1.4;
}

/* 移动端响应式适配 - 核心修改 */
@media (max-width: 768px) {
  /* 重置整体布局为垂直排列 */
  .main-content {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    overflow-y: auto;
    height: calc(100vh - 60px); /* 适配头部高度 */
  }

  /* 侧边栏全屏宽，高度自适应 */
  .sidebar {
    width: 100%;
    max-height: 50vh; /* 限制侧边栏高度，避免遮挡结果 */
    padding: 16px;
    gap: 12px;
  }

  /* 结果面板占满剩余高度 */
  .results-panel {
    flex: 1;
    min-height: 40vh;
  }

  /* 工具栏布局调整：垂直排列 */
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 16px;
  }

  /* 过滤行改为垂直排列 */
  .filter-row {
    flex-direction: column;
    gap: 8px;
  }

  /* 分页控件适配 */
  .pagination {
    width: 100%;
    justify-content: center;
  }

  /* 导出按钮组全屏宽 */
  .export-group {
    width: 100%;
    justify-content: space-between;
  }

  /* 文章卡片简化 */
  .article-card {
    padding: 12px;
    margin-bottom: 8px;
  }

  /* 移除卡片左侧序号（节省空间） */
  .article-card > div > div:first-child {
    display: none;
  }

  /* 期刊信息盒适配 */
  .journal-info-box {
    padding: 6px 8px;
    font-size: 11px;
  }

  /* 元信息行换行优化 */
  .meta-line {
    font-size: 12px;
    word-break: break-all;
  }

  /* 按钮字体缩小 */
  .btn {
    font-size: 12px;
    padding: 8px 12px;
  }

  /* 输入框适配 */
  input, select, textarea {
    font-size: 13px;
    padding: 8px;
  }

  /* 过滤状态固定在侧边栏底部，但不遮挡 */
  .filter-status {
    margin-top: 8px;
    padding-top: 8px;
    font-size: 10px;
  }

  /* 头部适配 */
  .header {
    padding: 0.6rem 1rem;
    font-size: 16px;
  }

  /* 状态标签缩小 */
  #status-tag {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* 结果列表内边距减小 */
  #results-list {
    padding: 8px;
  }
}

/* 小屏手机额外适配（480px以下） */
@media (max-width: 480px) {
  .sidebar {
    max-height: 60vh;
  }

  .operator-buttons {
    flex-direction: column; /* 逻辑运算符按钮垂直排列 */
  }

  .journal-info-item {
    padding: 2px 6px;
    font-size: 10px;
  }

  .export-group {
    flex-direction: column;
    gap: 4px;
  }

  .export-group .btn {
    width: 100%;
  }
}