/* --- 剧情规划大师 UI 优化 --- */

/* 1. 基础与字体设置 */
#qrf_settings_panel {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
    color: var(--text_color, #E0E0E0);
}

/* 2. 头部与尾部 */
#qrf_settings_panel .qrf-header {
    text-align: center;
    padding-bottom: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color, #3a3a3a);
}

#qrf_settings_panel .qrf-header h4 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 400; /* 更柔和的字重 */
    color: var(--text_color, #FFFFFF);
}

#qrf_settings_panel .qrf-header h4 i {
    margin-right: 12px;
    color: var(--primary, #00BFFF); /* 深天蓝作为强调色 */
}

#qrf_settings_panel .qrf_footer {
    text-align: center;
    padding-top: 15px;
    margin-top: 25px;
    border-top: 1px solid var(--border-color, #3a3a3a);
    font-size: 0.8em;
    color: var(--text_secondary, #999);
}

/* 3. 设置组 (Fieldset) */
#qrf_settings_panel .settings-group {
    background-color: var(--background-color-secondary, rgba(40, 40, 40, 0.8));
    border: 1px solid var(--border-color, #3a3a3a);
    padding: 20px 25px;
    margin-bottom: 25px;
    border-radius: 12px; /* 更大的圆角 */
    transition: border-color 0.3s ease;
}

#qrf_settings_panel .settings-group:hover {
    border-color: var(--primary-hover, #4FC3F7);
}

#qrf_settings_panel .settings-group legend {
    font-weight: 600;
    font-size: 1.15em;
    padding: 0 10px;
    color: var(--text_color, #F0F0F0);
}

#qrf_settings_panel .settings-group legend i {
    margin-right: 10px;
    color: var(--primary, #00BFFF);
}

/* 4. 设置项布局与标签 */
#qrf_settings_panel .qrf_settings_block,
#qrf_settings_panel .qrf_settings_block_radio {
    margin-bottom: 22px;
}

#qrf_settings_panel .qrf_settings_block label,
#qrf_settings_panel .qrf_settings_block_radio > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text_secondary, #CCCCCC);
    font-size: 0.9em;
}

#qrf_settings_panel .qrf_settings_block .notes,
#qrf_settings_panel .qrf_settings_block_hint {
    font-size: 0.8em;
    color: var(--text_tertiary, #999);
    margin-top: 8px;
    line-height: 1.5;
}

/* 5. 通用表单元素 (输入框, 下拉框) */
#qrf_settings_panel .text_pole,
#qrf_settings_panel select {
    width: 100%;
    background-color: var(--background-color, #1A1A1A);
    color: var(--text_color, #E0E0E0);
    border: 1px solid var(--border-color, #444);
    border-radius: 8px;
    padding: 12px;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

#qrf_settings_panel .text_pole:focus,
#qrf_settings_panel select:focus {
    outline: none;
    border-color: var(--primary, #00BFFF);
    box-shadow: 0 0 8px rgba(0, 191, 255, 0.25);
}

#qrf_settings_panel textarea.text_pole {
    resize: vertical;
    min-height: 90px;
}

/* 6. 特殊组合控件 */
#qrf_settings_panel .qrf_model_selector_wrapper,
#qrf_settings_panel .qrf_preset_selector_wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#qrf_settings_panel .qrf_model_selector_wrapper input,
#qrf_settings_panel .qrf_preset_selector_wrapper select {
    flex-grow: 1;
}

#qrf_settings_panel .qrf_label_with_button_wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#qrf_settings_panel .qrf_label_with_controls_wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px; /* 与下方列表的间距 */
}

#qrf_settings_panel #qrf_worldbook_entry_controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#qrf_settings_panel #qrf_worldbook_entry_count {
    font-size: 0.9em;
    color: var(--text_secondary, #ccc);
    margin-right: 5px; /* 与按钮的间距 */
}

/* 7. 开关 (Toggle Switch) */
#qrf_settings_panel .toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
#qrf_settings_panel .toggle-switch input {
    opacity: 0; width: 0; height: 0;
}
#qrf_settings_panel .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--background-color-tertiary, #555);
    transition: .3s;
    border-radius: 26px;
}
#qrf_settings_panel .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 50%;
}
#qrf_settings_panel input:checked + .slider {
    background-color: var(--primary, #00BFFF);
}
#qrf_settings_panel input:checked + .slider:before {
    transform: translateX(22px);
}

/* 总开关特殊样式 */
#qrf_settings_panel .settings-group > .qrf_settings_block:first-child {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
    margin-top: -5px; /*向上微调*/
}
#qrf_settings_panel .settings-group > .qrf_settings_block:first-child label {
    margin-bottom: 0;
}
#qrf_settings_panel .settings-group > .qrf_settings_block:first-child strong {
    font-size: 1.05em;
    color: var(--text_color, #FFFFFF);
}

/* 8. 滑块 (Range Input) */
#qrf_settings_panel input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--background-color-tertiary, #555);
    border-radius: 6px;
    outline: none;
    transition: opacity .2s;
}
#qrf_settings_panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #FFFFFF;
    border: 3px solid var(--primary, #00BFFF);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}
#qrf_settings_panel input[type="range"]:hover::-webkit-slider-thumb {
    background: #E0E0E0;
}
#qrf_settings_panel input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #FFFFFF;
    border: 3px solid var(--primary, #00BFFF);
    cursor: pointer;
    border-radius: 50%;
}

/* 9. 单选按钮 */
#qrf_settings_panel .qrf_radio_group {
    display: flex;
    gap: 10px 20px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 5px;
    background-color: var(--background-color, #1A1A1A);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #3a3a3a);
}
#qrf_settings_panel .qrf_radio_group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9em;
    margin-bottom: 0;
}
#qrf_settings_panel .qrf_radio_group input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--primary, #00BFFF);
}

/* API模式 - 2x2 网格布局 */
#qrf_settings_panel .qrf_api_mode_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px; /* 网格间距 */
    padding: 15px;
}
#qrf_settings_panel .qrf_api_mode_grid .qrf_radio_option {
    display: flex;
    align-items: center;
    background-color: var(--background-color-tertiary, #2a2a2a);
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}
#qrf_settings_panel .qrf_api_mode_grid .qrf_radio_option:hover {
    background-color: var(--background-color-hover, #3a3a3a);
}
#qrf_settings_panel .qrf_api_mode_grid .qrf_radio_option label {
    margin-bottom: 0;
    width: 100%;
}


/* 10. 世界书条目列表 */
.qrf_worldbook_entry_list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-color, #444);
    padding: 10px;
    border-radius: 8px;
    background-color: var(--background-color, #1A1A1A);
}

.qrf_worldbook_entry_item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.qrf_worldbook_entry_item:hover {
    background-color: var(--primary-hover-faded, rgba(0, 191, 255, 0.1));
}

.qrf_worldbook_entry_item input[type="checkbox"] {
    margin-right: 12px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary, #00BFFF);
}

.qrf_worldbook_entry_item label {
    font-size: 0.9em;
    cursor: pointer;
    user-select: none;
    color: var(--text_secondary, #ccc);
    margin-bottom: 0;
}

/* 11. 菜单按钮统一样式 */
#qrf_settings_panel .menu_button {
    height: 38px; /* 与输入框高度接近 */
    padding: 0 15px; /* 增加水平内边距 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 90px; /* 增加最小宽度以确保按钮等宽并容纳内容 */
    white-space: nowrap; /* 防止文字换行 */
}
