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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #0078d4;
    color: white;
    border-radius: 8px;
}

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

.container {
    display: flex;
    flex: 1;
    gap: 15px;
    overflow: hidden;
}

.links-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.links-header {
    padding: 10px;
    background-color: #f0f0f0;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.links-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.visited-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.visited-header {
    padding: 10px;
    background-color: #f0f0f0;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.visited-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.link-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-item:hover {
    background-color: #f5f5f5;
}

.visited-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.visited-item .link {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.visited-link {
    cursor: default;
    color: #666;
    text-decoration: none;
    pointer-events: none; /* 禁用鼠标事件 */
    opacity: 0.8; /* 稍微降低不透明度 */
}

.visited-item .delete-btn {
    background-color: #d9534f;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 12px;
}

.controls {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

button {
    background-color: #0078d4;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    flex: 1;
    margin: 0 5px;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

button:first-child {
    margin-left: 0;
}

button:last-child {
    margin-right: 0;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 18px;
    color: #666;
}

/* 移动设备优化 */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }
    
    header {
        margin-bottom: 10px;
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .status {
        font-size: 0.9rem;
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .container {
        flex-direction: column;
        gap: 10px;
    }
    
    .links-container, .visited-container {
        height: 250px; /* 减小高度以适应小屏幕 */
    }
    
    .links-header, .visited-header {
        padding: 8px;
        font-size: 0.9rem;
    }
    
    .links-list, .visited-list {
        padding: 5px;
    }
    
    .link-item, .visited-item {
        padding: 10px 8px; /* 增加垂直内边距以便于触摸 */
        font-size: 0.9rem;
    }
    
    .visited-item .delete-btn {
        padding: 5px 8px; /* 增大按钮尺寸以便于触摸 */
        font-size: 0.8rem;
    }
    
    .controls {
        margin-top: 10px;
    }
    
    button {
        padding: 12px 10px; /* 增大按钮尺寸以便于触摸 */
        font-size: 0.9rem;
        margin: 0 3px;
    }
}

/* 小型手机设备 */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .status {
        font-size: 0.8rem;
    }
    
    .links-container, .visited-container {
        height: 200px;
    }
    
    .link-item, .visited-item {
        padding: 12px 8px; /* 进一步增大触摸区域 */
    }
    
    button {
        padding: 14px 8px; /* 进一步增大触摸区域 */
        font-size: 0.85rem;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) {
    body {
        padding: 15px;
    }
    
    header {
        margin-bottom: 20px;
    }
    
    .controls {
        margin-top: 20px;
    }
    
    /* 在横屏模式下恢复水平布局 */
    @media (max-width: 768px) {
        .container {
            flex-direction: row;
        }
    }
}
