* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
}

.header {
    background: #34495e;
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    width: calc(100% - 270px);
    margin-left: 270px;
    box-sizing: border-box;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header h2 {
    font-size: 1.4em;
    margin-bottom: 15px;
    opacity: 0.95;
    font-weight: 400;
}

.header .author-info {
    position: absolute;
    bottom: 10px;
    right: 20px;
    font-size: 0.74em;
    opacity: 0.72;
    margin: 0;
}

.header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.container {
    display: flex;
    height: calc(100vh - 120px);
    width: calc(100% - 270px);
    margin-left: 270px;
}

.sidebar {
    width: 270px;
    background: white;
    padding: 16px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
}

.map-container {
    flex: 1;
    position: relative;
    height: 100%;
    min-height: 500px; /* 确保有最小高度 */
}

#map {
    width: 100%;
    height: 100%;
    min-height: 500px; /* 确保地图有最小高度 */
}

.filter-section {
    margin-bottom: 18px;
}

.filter-section h3 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1.1em;
    border-bottom: 2px solid #34495e;
    padding-bottom: 5px;
}

.filter-group {
    margin-bottom: 11px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: #555;
    font-size: 13px;
}

.filter-group select, .filter-group input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid #cbd2d9;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.3s;
}

.filter-group select:focus, .filter-group input:focus {
    outline: none;
    border-color: #34495e;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: #34495e;
    color: white;
}

.btn-primary:hover {
    background: #2c3e50;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 73, 94, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.filter-section .button-row {
    display: flex;
    gap: 8px;
}

.filter-section .button-row .btn {
    flex: 1;
    min-width: 0;
    width: auto;
    margin-bottom: 0;
    padding: 9px 5px;
    font-size: 12px;
    white-space: nowrap;
}

.stats {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stats h4 {
    color: #333;
    margin-bottom: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
}

.legend {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.legend h4 {
    margin-bottom: 10px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 14px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
}

.popup-content {
    min-width: 340px;
    max-width: 400px;
    max-height: 60vh; /* 限制最大高度 */
    overflow-y: auto; /* 允许垂直滚动 */
    padding-right: 10px; /* 为滚动条留出空间 */
}

.popup-header {
    color: #34495e;
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 10px;
    border-bottom: 2px solid #34495e;
    padding-bottom: 5px;
    position: sticky; /* 标题固定 */
    top: 0;
    background: white;
    z-index: 10;
}

.popup-summary {
    display: flex;
    max-width: 100%;
    margin: 0;
    color: #526575;
    font-size: 12px;
    white-space: nowrap;
}

.popup-location {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-match-count { flex: none; }

.program-item {
    background: #f8f9fa;
    margin: 10px 0;
    padding: 12px;
    border: 1px solid #e2e6ea;
    border-radius: 4px;
}

.program-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.program-title a {
    color: #007bff;
    text-decoration: none;
}

.program-title a:hover {
    text-decoration: underline;
}

.program-details {
    font-size: 0.9em;
    color: #666;
}

.program-details-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.program-details-top > span:not(.program-type-badge) {
    flex: none;
    white-space: nowrap;
}

.program-details-graduation {
    margin-top: 4px;
    line-height: 1.35;
}

.program-details .program-type-badge {
    padding: 2px 7px;
    border: 1px solid;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    text-transform: capitalize;
    vertical-align: baseline;
}

.program-details .program-type-professional { background: #eaf6fc; border-color: #9ccfe9; color: #225776; }
.program-details .program-type-research { background: #fcf9df; border-color: #d8cc80; color: #645814; }
.program-details .program-type-mixed { background: #fff0e7; border-color: #e6b99f; color: #943d12; }
.program-details .program-type-default { background: #edf1f4; border-color: #cbd5dd; color: #455668; }

.program-tracks {
    margin-top: 8px;
    font-size: 0.9em;
}

.program-tracks ul {
    margin: 4px 0 0 18px;
    padding: 0;
}

.program-tracks a {
    color: #007bff;
}

/* Custom marker styles */
.custom-marker {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
}

/* 确保leaflet的默认div图标样式被重置 */
.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

/* Loading animation */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
    font-size: 1.2em;
    color: #34495e;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #34495e;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message styles */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin: 20px;
    border: 1px solid #f5c6cb;
}

.error-message h4 {
    margin-bottom: 10px;
}

/* Success message styles */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin: 20px;
    border: 1px solid #c3e6cb;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        margin-left: 0;
        width: 100%;
    }
    
    .header h2 {
        display: none; /* 移动端隐藏副标题 */
    }
    
    .container {
        flex-direction: column;
        height: auto;
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        position: static;
        box-shadow: none;
        border-bottom: 1px solid #ddd;
    }
    
    .map-container {
        flex: 1;
        position: relative;
        margin-left: 0;
        height: 60vh; /* 给地图一个固定高度 */
        min-height: 400px;
    }
    
    #map {
        width: 100%;
        height: 100%;
        min-height: 400px; /* 移动端最小高度 */
    }
    
    /* 其他移动端样式保持不变 */
    .stats-legend-container {
        display: flex;
        gap: 10px;
        margin-bottom: 5px;
    }
    
    .stats, .legend {
        flex: 1;
        margin-bottom: 0;
    }
    
    .filters-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin-bottom: 15px;
    }
    
    .filters-grid .filter-group {
        margin-bottom: 0;
    }
    
    .filters-grid .filter-group label {
        font-size: 11px;
        margin-bottom: 3px;
    }
    
    .filters-grid .filter-group select,
    .filters-grid .filter-group input {
        padding: 5px 6px;
        font-size: 11px;
    }
    
    .button-row {
        display: flex;
        gap: 8px;
    }
    
    .button-row .btn {
        flex: 1;
        margin-bottom: 0;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .filter-section h3 {
        display: none;
    }
    
    .popup-content {
        max-width: 280px;
    }
    
    .legend-color {
        width: 10px;
        height: 10px;
        margin-right: 6px;
    }
    
    .suggest-edit-box {
        bottom: 20px;
        right: 10px;
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.3em;
    }
    
    .header h2 {
        font-size: 1em;
    }
    
    .sidebar {
        padding: 15px;
    }
    
    /* 在很小的屏幕上保持并列 */
    .stats-legend-container {
        gap: 8px;
    }
    
    .stats h4, .legend h4 {
        font-size: 0.7em;
        margin-bottom: 8px;
    }
    
    .stat-item {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .legend-item {
        margin-bottom: 4px;
        font-size: 11px;
    }
    
    /* 更小屏幕的过滤器网格 */
    .filters-grid {
        gap: 6px;
        margin-bottom: 12px;
    }
    
    .filters-grid .filter-group label {
        font-size: 11px;
        margin-bottom: 3px;
    }
    
    .filters-grid .filter-group select,
    .filters-grid .filter-group input {
        padding: 5px 6px;
        font-size: 11px;
    }
    
    /* 小屏幕上按钮行间距调整 */
    .button-row {
        gap: 6px;
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 14px;
    }
    
    .stats, .legend {
        padding: 5px 10px;
    }
    
    /* 更小屏幕上进一步缩小点 */
    .legend-color {
        width: 8px;
        height: 8px;
        margin-right: 5px;
    }
    
    .map-container {
        height: 50vh;
        min-height: 300px;
    }
}

/* Print styles */
@media print {
    .sidebar {
        display: none;
    }
    
    .map-container {
        width: 100%;
    }
    
    .header {
        background: #333 !important;
        -webkit-print-color-adjust: exact;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        color: #fff;
        border: 1px solid #fff;
    }
    
    .legend-color {
        border: 1px solid #000;
    }
    
    .popup-header {
        color: #000;
        border-bottom-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .filter-group select,
    .filter-group input {
        transition: none;
    }
    
    .spinner {
        animation: none;
    }
    
    .btn-primary:hover {
        transform: none;
    }
}

/* 为表单元素指定字体 */
select, input, button {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 或者更具体地针对你的过滤器元素 */
.filters select,
.filters input,
.filters button {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Custom tooltip styles */
.custom-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    white-space: nowrap !important;
    min-width: 300px !important;
    max-width: 450px !important;
    text-align: center !important;
}

.custom-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

/* 响应式tooltip */
@media (max-width: 768px) {
    .custom-tooltip {
        font-size: 12px !important;
        padding: 8px 16px !important;
        min-width: 250px !important;
        max-width: 350px !important;
    }
}

@media (max-width: 480px) {
    .custom-tooltip {
        font-size: 11px !important;
        padding: 6px 12px !important;
        min-width: 200px !important;
        max-width: 280px !important;
    }
}

/* User Notes Styles */
.user-notes {
    margin-top: 6px;
}

.user-notes .note-form { margin-top: 8px; }

.note-buttons {
    display: flex;
    gap: 6px;
}

.note-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.note-btn:hover {
    background: #e9ecef;
}

.save-toggle.is-saved {
    background: #fff3cd;
    border-color: #e5b84a;
    color: #483600;
}

.note-form[hidden] {
    display: none;
}

.note-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
}

.note-form textarea {
    display: block;
    width: 100%;
    min-height: 70px;
    margin: 5px 0;
    padding: 8px;
    border: 1px solid #aab2ba;
    border-radius: 4px;
    resize: vertical;
    font: inherit;
}

.note-form button,
.saved-card-actions button {
    padding: 6px 9px;
    border: 1px solid #9aa5ae;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.saved-note-preview {
    margin-top: 7px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 12px;
    color: #475569;
}

.saved-panel,
.results-section {
    margin: 18px 0;
    padding-top: 14px;
    border-top: 2px solid #e2e8f0;
}

.saved-panel summary {
    cursor: pointer;
    font-weight: 700;
    color: #34495e;
}

#saved-count {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 12px;
    background: #34495e;
    color: white;
    text-align: center;
    font-size: 12px;
}

.saved-help,
.empty-state {
    margin: 10px 0;
    color: #586675;
    font-size: 12px;
    line-height: 1.4;
}

.saved-card,
.result-card {
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
    overflow-wrap: anywhere;
}

.saved-card strong,
.saved-card a {
    display: block;
    font-size: 13px;
}

.saved-card a {
    margin-top: 3px;
}

.saved-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.results-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.results-heading-row h3 {
    font-size: 14px;
    color: #34495e;
    white-space: nowrap;
}

.results-heading-row select {
    max-width: 112px;
    min-width: 0;
    padding: 5px;
    border: 1px solid #aab2ba;
    border-radius: 4px;
    font-size: 12px;
}

.results-list {
    max-height: 370px;
    overflow-y: auto;
}

.result-focus {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    color: #205b9c;
    font-weight: 700;
    cursor: pointer;
}

.result-focus span {
    display: block;
    margin-top: 3px;
    color: #34495e;
    font-size: 12px;
    font-weight: 400;
}

.result-meta {
    margin: 6px 0;
    color: #586675;
    font-size: 11px;
}

.action-status {
    position: fixed;
    bottom: 20px;
    left: 320px;
    z-index: 2200;
    padding: 10px 14px;
    border-radius: 6px;
    background: #20384f;
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.action-status.visible {
    opacity: 1;
}

.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .results-list { max-height: 230px; }
    .action-status { left: 12px; right: 12px; bottom: 12px; }
}

.wishlist-btn.active {
    background: #fff3cd;
    border-color: #ffeaa7;
}

.note-btn.active {
    background: #d1ecf1;
    border-color: #bee5eb;
}

.note-input {
    margin-top: 8px;
}

.note-input textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    resize: vertical;
    box-sizing: border-box;
}

.note-input button {
    background: #34495e;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 4px;
}

.note-input button:hover {
    background: #2c3e50;
}

.saved-notes {
    margin-top: 8px;
}

.wishlist-display, .note-display {
    background: #f8f9fa;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 4px;
    border-left: 3px solid #34495e;
}

.wishlist-display {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.note-display {
    background: #d1ecf1;
    border-left-color: #17a2b8;
}

/* Export button */
.export-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.export-btn {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.export-btn:hover {
    background: #2b468c;
}

/* Info Icon and Modal Styles */
.author-info {
    position: absolute;
    bottom: 10px;
    right: 20px;
    font-size: 0.9em;
    opacity: 0.8;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
}

.info-icon:hover {
    color: white;
    transform: scale(1.1);
}

/* Info Modal */
.info-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
    overflow-y: auto; /* 允许模态框本身滚动 */
}

.info-modal-content {
    background-color: white;
    margin: 5% auto; /* 减少顶部边距，给更多空间 */
    padding: 20px 22px;
    border-radius: 12px;
    width: 50%;
    max-width: 800px;
    min-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideIn 0.3s ease;
    max-height: 90vh; /* 限制最大高度 */
    overflow-y: auto; /* 内容区域可滚动 */
}

.info-modal-content h3 {
    color: #34495e;
    margin-bottom: 12px;
    font-size: 1.25em;
    border-bottom: 2px solid #34495e;
    padding-bottom: 6px;
    padding-right: 36px; /* Leave room for the close button */
}

.info-text {
    font-size: 0.88em;
    line-height: 1.35;
    color: #333;
    padding-bottom: 10px; /* 底部留白 */
}

.info-text p {
    margin-bottom: 8px;
}

.info-text strong {
    color: #34495e;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 20; /* 确保关闭按钮在最上层 */
}

.close:hover {
    color: #34495e;
}

/* Info Tooltip */
.info-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1500;
    white-space: nowrap;
    transform: translateX(15%)
}

.info-tooltip.show {
    opacity: 1;
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%; /* 箭头在tooltip底部 */
    right: 20px; /* 箭头在tooltip右侧，指向icon */
    transform: translateX(0);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8); /* 箭头向上指向icon */
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design for modal */
@media (max-width: 768px) {
    .info-modal-content {
        width: 95%;
        min-width: 300px;
        margin: 2% auto; /* 更小的边距 */
        padding: 16px 18px;
        max-height: 96vh; /* 移动端更多空间 */
    }
    
    .info-modal-content h3 {
        font-size: 1.12em;
        padding: 6px 36px 6px 0;
        margin-bottom: 10px;
    }
    
    .info-text {
        font-size: 12px;
        line-height: 1.35;
    }
    
    .close {
        top: 10px;
        right: 15px;
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .info-modal-content {
        width: 98%;
        margin: 1% auto;
        padding: 12px 14px;
        max-height: 98vh;
    }
    
    .info-modal-content h3 {
        font-size: 1.02em;
    }
    
    .info-text {
        font-size: 11px;
    }
}

/* Suggest Edit Box */
.suggest-edit-box {
    position: absolute;
    bottom: 60px;
    right: 20px;
    background: #34495e;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    z-index: 1000;
}

.suggest-edit-box:hover {
    background: #2c3e50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.suggest-edit-box i {
    font-size: 16px;
}

/* Suggest Edit Modal */
.suggest-edit-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
}

.suggest-edit-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 50%;
    max-width: 600px;
    min-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.suggest-edit-modal-content h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.5em;
    border-bottom: 2px solid #34495e;
    padding-bottom: 10px;
}

.suggest-edit-text {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.5;
}

.suggest-edit-text p {
    margin: 0;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #34495e;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-buttons button[type="button"] {
    background: #6c757d;
    color: white;
}

.form-buttons button[type="button"]:hover {
    background: #5a6268;
}

.form-buttons button[type="submit"] {
    background: #34495e;
    color: white;
}

.form-buttons button[type="submit"]:hover {
    background: #2c3e50;
}

/* Responsive */
@media (max-width: 768px) {
    .suggest-edit-modal-content {
        width: 95%;
        min-width: 300px;
        margin: 2% auto;
        padding: 20px;
    }
    
    .suggest-edit-box {
        bottom: 50px;
        right: 10px;
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* 移动端popup调整 */
@media (max-width: 768px) {
    .popup-content {
        min-width: 0;
        max-width: 280px;
        max-height: 70vh; /* 移动端更多空间 */
    }
    
    .popup-header {
        font-size: 1.1em;
    }
    
    .program-item {
        padding: 10px;
        margin: 8px 0;
    }
    
    .program-details {
        font-size: 0.8em;
    }

    .program-details-top {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.2fr);
    }

    .program-details-top > span:not(.program-type-badge) {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .note-btn {
        font-size: 11px;
        padding: 2px 6px;
    }
    
    .note-input textarea {
        min-height: 50px;
        font-size: 11px;
    }
    
    .note-input button {
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .popup-content {
        max-width: 250px;
        max-height: 75vh;
    }
    
    .popup-header {
        font-size: 1em;
    }
    
    .program-item {
        padding: 8px;
        margin: 6px 0;
    }
    
    .program-details {
        font-size: 0.75em;
    }

    .program-details-top { gap: 6px; }
}

/* Applied filters and mobile filter panel */
.mobile-filter-toggle { display: none; }
#filter-controls[hidden], .compare-modal[hidden] { display: none; }
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: -8px 0 18px;
    line-height: 1.4;
}
.active-filters-label {
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: #455668;
}
.filter-chip {
    max-width: 100%;
    padding: 5px 9px;
    border: 1px solid #7c9ab5;
    border-radius: 16px;
    background: #eaf3fa;
    color: #193d5b;
    overflow-wrap: anywhere;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
}
.filter-chip span { margin-left: 4px; font-size: 15px; font-weight: 700; }
.clear-active-filters {
    padding: 5px 3px;
    border: 0;
    background: none;
    color: #205b9c;
    text-decoration: underline;
    cursor: pointer;
    font-size: 12px;
}

/* Saved program comparison */
.compare-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    cursor: pointer;
}
.compare-choice input { width: 16px; height: 16px; }
.compare-open {
    width: 100%;
    padding: 10px;
    margin: 12px 0 8px;
    border: 0;
    border-radius: 6px;
    background: #34495e;
    color: white;
    font-weight: 700;
    cursor: pointer;
}
.compare-open:disabled { opacity: 0.5; cursor: not-allowed; }
.compare-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
}
.compare-dialog {
    width: min(1100px, 100%);
    max-height: 90vh;
    padding: 20px;
    border-radius: 10px;
    background: white;
    overflow-y: auto;
}
.compare-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.compare-header h2 { color: #34495e; font-size: 20px; }
#compare-close {
    min-width: 36px;
    min-height: 36px;
    border: 0;
    border-radius: 5px;
    background: #e5eaf0;
    font-size: 25px;
    cursor: pointer;
}
.compare-dialog > p { margin: 10px 0; color: #586675; font-size: 13px; }
.compare-scroll { max-width: 100%; overflow-x: auto; }
.compare-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    table-layout: fixed;
}
.compare-table th, .compare-table td {
    width: 220px;
    padding: 12px;
    border: 1px solid #d5dde5;
    vertical-align: top;
    text-align: left;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 13px;
}
.compare-table th:first-child {
    position: sticky;
    left: 0;
    width: 155px;
    background: #edf3f8;
    z-index: 1;
}
.compare-table thead th { background: #34495e; color: white; }
.compare-table thead th:first-child { background: #34495e; z-index: 2; }

@media (max-width: 768px) {
    .filter-section { margin-bottom: 16px; }
    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid #aab2ba;
        border-radius: 6px;
        background: #f4f8fb;
        color: #20384f;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
    }
    #mobile-filter-count {
        display: inline-block;
        min-width: 21px;
        padding: 2px 5px;
        border-radius: 11px;
        background: #34495e;
        color: white;
        text-align: center;
        font-size: 11px;
    }
    .filter-toggle-label { color: #205b9c; font-size: 12px; }
    .active-filters { margin-top: 0; }
    .compare-modal { padding: 8px; }
    .compare-dialog { padding: 12px; max-height: 96vh; }
    .compare-table th, .compare-table td { width: 190px; padding: 9px; }
    .compare-table th:first-child { width: 100px; }
}

/* Floating saved shortlist */
@media (min-width: 769px) {
    body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
    .header { flex: none; }
    .container { flex: 1; height: auto; min-height: 0; }
    .map-container, #map { min-height: 0; }
}
.saved-launcher {
    position: absolute;
    left: 20px;
    bottom: 20px;
    z-index: 1005;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: #34495e;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.3s ease;
    cursor: pointer;
}
.saved-launcher:hover, .saved-launcher[aria-expanded="true"] { background: #2c3e50; }
.saved-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.saved-launcher i { color: white; font-size: 16px; }
.saved-launcher #saved-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 50px;
    background: rgba(255,255,255,.18);
    color: white;
    font-size: 11px;
}
.saved-drawer[hidden], .saved-backdrop[hidden] { display: none; }
.saved-backdrop { display: none; }
.saved-drawer {
    position: absolute;
    left: 20px;
    bottom: 78px;
    z-index: 1006;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100% - 40px));
    max-height: min(650px, calc(100% - 98px));
    border: 1px solid #d8e0e6;
    border-radius: 14px;
    background: #f7f9fa;
    box-shadow: 0 12px 32px rgba(18, 41, 59, 0.18);
    overflow: hidden;
    font-family: inherit;
}
.saved-drawer button, .saved-drawer textarea { font-family: inherit; }
.saved-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: none;
    padding: 10px 14px;
    border-bottom: 1px solid #e1e6ea;
    background: #fff;
}
.saved-drawer-header h3 {
    margin: 0;
    color: #263746;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
.saved-close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #516170;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}
.saved-close:hover { background: #f0f3f5; }
.saved-list { min-height: 0; padding: 12px; overflow-y: auto; }
.saved-school + .saved-school { margin-top: 13px; }
.saved-school h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0 2px 7px;
    color: #526575;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
}
.saved-school-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-school-count {
    flex: none;
    min-width: 18px;
    padding: 2px 5px;
    border-radius: 10px;
    background: #e3e9ed;
    text-align: center;
    font-size: 10px;
}
.saved-drawer .saved-card {
    margin: 0 0 7px;
    padding: 8px 10px 5px;
    border: 1px solid #dce3e8;
    border-radius: 12px;
    background: #fff;
    box-shadow: none;
}
.saved-drawer .saved-program-link {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    margin: 0;
    padding-left: 7px;
    color: #263f53;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.saved-drawer .saved-program-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-drawer .saved-program-link:hover span { text-decoration: underline; }
.saved-drawer .saved-program-link i { flex: none; font-size: 11px; }
.saved-drawer .saved-card-actions { display: flex; align-items: center; gap: 2px; margin: 4px 0 0; }
.saved-drawer .saved-card-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 30px;
    padding: 0 6px;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: #526575;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}
.saved-drawer .saved-card-actions button:hover { background: #edf1f4; color: #263f53; }
.saved-drawer .saved-card-actions .saved-remove { margin-left: auto; }
.saved-drawer .saved-card-actions .saved-remove:hover { background: #fbeceb; color: #9d3431; }
.saved-drawer .compare-choice {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    margin: 0;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 20px;
    color: #526575;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
}
.saved-drawer .compare-choice:hover { background: #edf1f4; }
.saved-drawer .compare-choice:has(input:checked) { background: #e4ecf2; color: #263f53; }
.saved-drawer .compare-choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.saved-drawer .compare-choice input { flex: none; width: 14px; height: 14px; margin: 0; accent-color: #34495e; }
.saved-drawer :is(a, button, .compare-choice):focus-visible { outline: 2px solid #34495e; outline-offset: 2px; }
.saved-drawer .saved-note-preview {
    display: -webkit-box;
    margin-top: 5px;
    padding-left: 7px;
    overflow: hidden;
    color: #6a7884;
    font-size: 12px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}
.saved-drawer .note-form { margin-top: 7px; }
.saved-drawer-footer {
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #e3eaf0;
    background: #fff;
}
.saved-drawer-footer p { grid-column: 1 / -1; margin: 0; color: #65798a; font-size: 11px; }
.saved-drawer .compare-open, .saved-drawer .export-btn {
    width: 100%;
    min-height: 34px;
    margin: 0;
    padding: 6px 7px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
}
.saved-drawer .export-btn { background: white; border: 1px solid #c5d4df; color: #2a506d; }
.saved-drawer .export-btn:hover { background: #e8f1f7; }
.saved-drawer .export-btn i { margin-right: 4px; }
.saved-empty { padding: 30px 12px; text-align: center; color: #617588; }
.saved-empty i { display: block; margin-bottom: 12px; color: #7ea5bd; font-size: 26px; }
.saved-empty strong { display: block; color: #27445b; font-size: 13px; font-weight: 600; }
.saved-empty p { margin: 5px 0 0; font-size: 12px; }

@media (max-width: 768px) {
    .saved-launcher { position: fixed; left: 12px; bottom: 12px; z-index: 1400; }
    .saved-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 1490;
        display: block;
        background: rgba(17, 35, 49, .45);
    }
    .saved-drawer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1500;
        width: 100%;
        max-height: 78vh;
        border-radius: 16px 16px 0 0;
    }
}
